Skip to content

Conversation

@r-zander
Copy link
Collaborator

api/effects.json Outdated
[
{
"id": 1,
"name": "QuickEscape",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erster, super simpler Effekt. Wird genutzt um Dodos einen kleinen Sprint zu geben, wenn sie geschlagen werden.

// Parse effects
var effectsByEvent = &EffectsByEvent{}
var err error
if effectsByEvent.WhileCarried, err = effects.MapAndValidateEffects(r, "WhileCarried", i.Effects.WhileCarried); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gibt es eine Variante um das schöner zu lösen statt 3 Zeilen pro Event-Parsing zu haben?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich würde das ganze ein wenig flexibler gestalten, wenn du jedoch deinen fixen struct befüllst kommst du wohl kaum um die Zeilen rum. Ev. könntest to ein bisschen reflect nutzen.

@@ -1,4 +1,4 @@
import {isDefined, removeElement} from "./Utils";
import {isDefined, isUndefined, removeElement} from "./Utils";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kannst du ignorieren, das war nur ein Fehler den ich im Frontend gefixt habe

@r-zander
Copy link
Collaborator Author

Meine Hauptfragen wären:

  • Was hältst du von der Package-Struktur wie ich sie jetzt für die Effekte genutzt habe?
  • Siehst du irgendwelche Änderungen, die extrem zulasten der Performance gehen?
  • Es gibt einen weirden Bug, dass das EffectSystem irgendwie dafür sorgt, dass sys.Update und sys.State nicht mehr richtig herum ausgeführt werden. Das führt sichtbar dazu, dass cheat: KILL nicht mehr funktioniert (da der Player leben regeneriert bevor er als tot aus dem Spiel entfernt wird), aber evtl gibt es noch weitere üble Nebenwirkungen. Ich kann mir leider absolut nicht erklären, warum - immerhin zählt das system nur die effekt durations herunter.

@r-zander r-zander requested a review from trichner October 24, 2019 21:50
@trichner
Copy link
Owner

uiii, sexy! Ich führ mir das mal zu Gemüte am Wochenende 👍

"type": "integer",
"description": "Number of times this effect can be applied simultaneously to the same entity. Omitting this property means no limit to the stack size.",
"minimum": 1,
"default": "infinity"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sollte nicht 0 als 'infinity' gelten? typisierte Sprachen haben für int kaum ein infinity definiert ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da habe ich eine Weile überlegt. Ich habe es so implementiert, dass "Wert nicht definiert im JSON" als nil herumgereicht wird, und dann maxStacks ignoriert wird. Natürlich könnte man das auch als 0 annehmen, aber dann würde der Default mit dem Minimum kollidieren, daher meine Angabe "infinity" (die natürlich nicht als Integer.INFINITY gelöst ist, sondern eben als nil) an den User adressiert, von wegen "wenn du nichts angibt, kann der Effekt beliebig oft stacken"

Copy link
Owner

@trichner trichner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cooles Ding!

Ich würde unbedingt das addieren/subtrahieren unterlassen, du hast eine gute Wahrscheinlichkeit dass a * x / x != a da die Operationen im Allgemeinen lossy sind. Ich würde die Effekte für jeden Tick wieder frisch aufaddieren, wenns zu hart ist für die performance liesse sich das dann auch einfach cachen...

Im Allgemeinen scheint mir die momentane Lösung skaliert relativ schlecht, wie du bereits selber gemerkt hast repetiert sich einiges relativ oft.

@@ -0,0 +1,188 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://berryhunter.io/schema/effects.json",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Inventory{
items: make([]*ItemStack, 0, 10),
cap: DEFAULT_INVENTORY_CAP,
effectEntity: p,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warum sind effekte teil des inventars?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weil das Inventar sonst nicht weiß, zu wem es gehört und wohin die Effekte der Items im Inventar zu applyen sind. Bin offen für eine bessere Lösung, aber sehe es nicht so recht, da diese Effect entity tatsächlich relativ oft gebraucht wird:
image

// Cap returns the maximum amount of item slots
func (i *Inventory) Cap() int {
return i.cap
return i.cap + i.effectEntity.EffectStack().Factors().InventoryCap
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kannst du das nicht generischer lösen?

// Parse effects
var effectsByEvent = &EffectsByEvent{}
var err error
if effectsByEvent.WhileCarried, err = effects.MapAndValidateEffects(r, "WhileCarried", i.Effects.WhileCarried); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich würde das ganze ein wenig flexibler gestalten, wenn du jedoch deinen fixen struct befüllst kommst du wohl kaum um die Zeilen rum. Ev. könntest to ein bisschen reflect nutzen.

for _, p := range s.players {

if p.VitalSigns().Health == 0 {
if p.VitalSigns().Health <= 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warum? Ziemlich sicher sind die VitalSigns gegen over- und underflow geschützt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da habe ich wohl rumgespielt, um den angesprochenen Bug zu beheben

Es gibt einen weirden Bug, dass das EffectSystem irgendwie dafür sorgt, dass sys.Update und sys.State nicht mehr richtig herum ausgeführt werden. Das führt sichtbar dazu, dass cheat: KILL nicht mehr funktioniert (da der Player leben regeneriert bevor er als tot aus dem Spiel entfernt wird), aber evtl gibt es noch weitere üble Nebenwirkungen. Ich kann mir leider absolut nicht erklären, warum - immerhin zählt das system nur die effekt durations herunter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants