Skip to main content
Grammar, punctuation and format
Source Link
Gnemlock
  • 5.3k
  • 5
  • 30
  • 60

This iswas an actual question for for me. And I have one idea about it.

  1. like says above, we need to implements buffs list and buff-logic updater

    As previously said, we need to implement a Buff list and a logic updater for the buffs.
  2. change all specific player settings every frame in subclasses of Buff class

    We then need to change all specific player settings every frame in subclasses of the Buff class.
  3. get current player settings from changable settings-field

    class Player { settings: AllPlayerStats;

    private buffs: Array = []; private baseSettings: AllPlayerStats;

    constructor(settings: AllPlayerStats) { this.baseSettings = settings; this.resetSettings(); }

    addBuff(buff: Buff): void { this.buffs.push(buff); buff.start(this); }

    findBuff(predcate(buff: Buff) => boolean): Buff {...}

    removeBuff(buff: Buff): void {...}

    update(dt: number): void { this.resetSettings(); this.buffs.forEach((item) => item.update(dt)); }

    private resetSettings(): void { //some way to copy base to settings this.settings = this.baseSettings.copy(); } }

    class Buff { private owner: Player;

     start(owner: Player) { this.owner = owner; }
    
     update(dt: number): void {
       //here we change anything we want in subclasses like
       this.owner.settings.hp += 15;
       //if we need base value, just make owner.baseSettings public but don't change it! only read
    
       //also here logic for removal buff by time or something
     }
    

    }

    We then get the current player settings from changable settings field.

class Player {
  settings: AllPlayerStats;

  private buffs: Array<Buff> = [];
  private baseSettings: AllPlayerStats;

  constructor(settings: AllPlayerStats) {
    this.baseSettings = settings;
    this.resetSettings();
  }

  addBuff(buff: Buff): void {
    this.buffs.push(buff);
    buff.start(this);
  }

  findBuff(predcate(buff: Buff) => boolean): Buff {...}

  removeBuff(buff: Buff): void {...}

  update(dt: number): void {
    this.resetSettings();
    this.buffs.forEach((item) => item.update(dt));
  }

  private resetSettings(): void {
    //some way to copy base to settings
    this.settings = this.baseSettings.copy();
  }
}

class Buff {
    private owner: Player;        

    start(owner: Player) { this.owner = owner; }

    update(dt: number): void {
      //here we change anything we want in subclasses like
      this.owner.settings.hp += 15;
      //if we need base value, just make owner.baseSettings public but don't change it! only read

      //also here logic for removal buff by time or something
    }
}

weIn this way, it can be easy to add new player statstats, with no change in buff-subclassesto the logic of the Buff subclasses.

This is actual question for me. And I have one idea about it.

  1. like says above, we need to implements buffs list and buff-logic updater

  2. change all specific player settings every frame in subclasses of Buff class

  3. get current player settings from changable settings-field

    class Player { settings: AllPlayerStats;

    private buffs: Array = []; private baseSettings: AllPlayerStats;

    constructor(settings: AllPlayerStats) { this.baseSettings = settings; this.resetSettings(); }

    addBuff(buff: Buff): void { this.buffs.push(buff); buff.start(this); }

    findBuff(predcate(buff: Buff) => boolean): Buff {...}

    removeBuff(buff: Buff): void {...}

    update(dt: number): void { this.resetSettings(); this.buffs.forEach((item) => item.update(dt)); }

    private resetSettings(): void { //some way to copy base to settings this.settings = this.baseSettings.copy(); } }

    class Buff { private owner: Player;

     start(owner: Player) { this.owner = owner; }
    
     update(dt: number): void {
       //here we change anything we want in subclasses like
       this.owner.settings.hp += 15;
       //if we need base value, just make owner.baseSettings public but don't change it! only read
    
       //also here logic for removal buff by time or something
     }
    

    }

we can easy to add new player stat with no change in buff-subclasses logic

This was an actual question for me. I have one idea about it.

  1. As previously said, we need to implement a Buff list and a logic updater for the buffs.
  2. We then need to change all specific player settings every frame in subclasses of the Buff class.
  3. We then get the current player settings from changable settings field.

class Player {
  settings: AllPlayerStats;

  private buffs: Array<Buff> = [];
  private baseSettings: AllPlayerStats;

  constructor(settings: AllPlayerStats) {
    this.baseSettings = settings;
    this.resetSettings();
  }

  addBuff(buff: Buff): void {
    this.buffs.push(buff);
    buff.start(this);
  }

  findBuff(predcate(buff: Buff) => boolean): Buff {...}

  removeBuff(buff: Buff): void {...}

  update(dt: number): void {
    this.resetSettings();
    this.buffs.forEach((item) => item.update(dt));
  }

  private resetSettings(): void {
    //some way to copy base to settings
    this.settings = this.baseSettings.copy();
  }
}

class Buff {
    private owner: Player;        

    start(owner: Player) { this.owner = owner; }

    update(dt: number): void {
      //here we change anything we want in subclasses like
      this.owner.settings.hp += 15;
      //if we need base value, just make owner.baseSettings public but don't change it! only read

      //also here logic for removal buff by time or something
    }
}

In this way, it can be easy to add new player stats, with no change to the logic of the Buff subclasses.

Source Link

This is actual question for me. And I have one idea about it.

  1. like says above, we need to implements buffs list and buff-logic updater

  2. change all specific player settings every frame in subclasses of Buff class

  3. get current player settings from changable settings-field

    class Player { settings: AllPlayerStats;

    private buffs: Array = []; private baseSettings: AllPlayerStats;

    constructor(settings: AllPlayerStats) { this.baseSettings = settings; this.resetSettings(); }

    addBuff(buff: Buff): void { this.buffs.push(buff); buff.start(this); }

    findBuff(predcate(buff: Buff) => boolean): Buff {...}

    removeBuff(buff: Buff): void {...}

    update(dt: number): void { this.resetSettings(); this.buffs.forEach((item) => item.update(dt)); }

    private resetSettings(): void { //some way to copy base to settings this.settings = this.baseSettings.copy(); } }

    class Buff { private owner: Player;

     start(owner: Player) { this.owner = owner; }
    
     update(dt: number): void {
       //here we change anything we want in subclasses like
       this.owner.settings.hp += 15;
       //if we need base value, just make owner.baseSettings public but don't change it! only read
    
       //also here logic for removal buff by time or something
     }
    

    }

we can easy to add new player stat with no change in buff-subclasses logic