From f311db38cb1f1f7a93dbb3a6e454cb9420975375 Mon Sep 17 00:00:00 2001 From: PAVLOS ARAMPATZIS <92672537+paulosaramp@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:18:23 +0000 Subject: [PATCH 1/5] Bounty Hunter Passive and 1 new Matrix 1)added a new matrice, "allaround1hex" it's a matrix showing which hexes are directly next to a 1 hex unit 2)added the new js file for bounty hunter, passive is done, needs testing --- src/abilities/Bounty-Hunter | 75 +++++++++++++++++++++++++++++++++++++ src/utility/matrices.js | 9 +++++ 2 files changed, 84 insertions(+) create mode 100644 src/abilities/Bounty-Hunter diff --git a/src/abilities/Bounty-Hunter b/src/abilities/Bounty-Hunter new file mode 100644 index 000000000..a5c37727f --- /dev/null +++ b/src/abilities/Bounty-Hunter @@ -0,0 +1,75 @@ +import { Damage } from '../damage'; +import { Team, isTeam } from '../utility/team'; +import * as matrices from '../utility/matrices'; +import * as arrayUtils from '../utility/arrayUtils'; +import { Creature } from '../creature'; +import { Effect } from '../effect'; + +/** Creates the abilities + * @param {Object} G the game object + * @return {void} + */ + +export default (G) => { + G.abilities[1] = [ + /** First Ability: + * Passive: + * Personal Space: + * Gains bonus stat points if there is an adjacent enemy unit when turn starts. + * 50% offense and movement increase. + * Upgrade: Bonus is increased to 100%. + */ + { + trigger: 'onStartPhase', + + _effectName: 'PersonalSpaceActivated', //name of the status + + getBuff: function () { + //decides how many much the base value is modified by the buff, 50% if not upgraded and 100% if upgraded + if (this.isUpgraded()) { + return 1; + } else return 0.5; + }, + + require: function () { + // Check requirements in activate() so the ability is always highlighted + return this.testRequirements(); + }, + + activate: function () { + //check if there's any enemy next to Bounty Hunter + let hexesAllAround = this.creature.getHexMap(matrices.allaround1hex); + if (hexesAllAround.length < 1) { + return; + } + let target = hexesAllAround[0].creature; + if (!target) { + return; + } + if (!isTeam(this.creature, target, Team.Enemy)) { + return; + } + + this.end(); + + this.creature.addEffect( + new Effect( + this._effectName, + this.creature, + this.creature, + '', + { + alterations: { + movement: this.creature.stats.movement * this.getBuff, + offense: this.creature.stats.offense * this.getBuff, + }, + deleteTrigger: 'onStartPhase', + turnLifetime: 1, + }, + G, + ), + ); + }, + }, + ]; +}; diff --git a/src/utility/matrices.js b/src/utility/matrices.js index 9063edf87..bb68c1f4c 100644 --- a/src/utility/matrices.js +++ b/src/utility/matrices.js @@ -36,6 +36,15 @@ export const bellowrow = [ bellowrow.origin = [0, 0]; +export const allaround1hex = [ + [0, 0, 0, 0], + [0, 1, 1, 0], + [1, 0, 1, 0], //Origin line + [0, 1, 1, 0], +]; + +allaround1hex.origin = [2, 2]; + export const frontnback2hex = [ [0, 0, 0, 0], [0, 1, 0, 1], From 40e770154b2e39371923062e01ebff9c83dc9f53 Mon Sep 17 00:00:00 2001 From: PAVLOS ARAMPATZIS <92672537+paulosaramp@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:25:55 +0000 Subject: [PATCH 2/5] commit --- src/abilities/{Bounty-Hunter => Bounty-Hunter.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/abilities/{Bounty-Hunter => Bounty-Hunter.js} (100%) diff --git a/src/abilities/Bounty-Hunter b/src/abilities/Bounty-Hunter.js similarity index 100% rename from src/abilities/Bounty-Hunter rename to src/abilities/Bounty-Hunter.js From 2826eb9f207c560caf1ba64ac946461bfe6acb96 Mon Sep 17 00:00:00 2001 From: PAVLOS ARAMPATZIS <92672537+paulosaramp@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:46:48 +0000 Subject: [PATCH 3/5] set BH playable --- src/data/units.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/units.json b/src/data/units.json index e135a4ad4..6ac8c15db 100644 --- a/src/data/units.json +++ b/src/data/units.json @@ -93,7 +93,7 @@ { "id": 1, "name": "Bounty Hunter", - "playable": false, + "playable": true, "level": 2, "realm": "A", "size": 1, From a74e6700765cc0a91f7c393ed77fcfc11e5cd145 Mon Sep 17 00:00:00 2001 From: PAVLOS ARAMPATZIS <92672537+paulosaramp@users.noreply.github.com> Date: Wed, 15 Feb 2023 20:28:02 +0000 Subject: [PATCH 4/5] commit --- src/abilities/Bounty-Hunter.js | 413 ++++++++++++++++++++++++++++++--- src/data/units.json | 2 +- src/utility/matrices.js | 9 - 3 files changed, 382 insertions(+), 42 deletions(-) diff --git a/src/abilities/Bounty-Hunter.js b/src/abilities/Bounty-Hunter.js index a5c37727f..7005a066e 100644 --- a/src/abilities/Bounty-Hunter.js +++ b/src/abilities/Bounty-Hunter.js @@ -1,16 +1,20 @@ +import * as $j from 'jquery'; import { Damage } from '../damage'; -import { Team, isTeam } from '../utility/team'; +import { Team } from '../utility/team'; import * as matrices from '../utility/matrices'; import * as arrayUtils from '../utility/arrayUtils'; -import { Creature } from '../creature'; import { Effect } from '../effect'; /** Creates the abilities * @param {Object} G the game object * @return {void} */ - export default (G) => { + /* + * + * Bounty Hunter abilities + * NOTICE: Abilities 3 and 4 are placeholders from Swine-Thug, they are there so the game doesn't break during testing + */ G.abilities[1] = [ /** First Ability: * Passive: @@ -19,56 +23,401 @@ export default (G) => { * 50% offense and movement increase. * Upgrade: Bonus is increased to 100%. */ + //TODO: Bug: Currently the movement buff is applied on the next turn instead { trigger: 'onStartPhase', - _effectName: 'PersonalSpaceActivated', //name of the status + require: function () { + // The ability is always active, but the bonuses are 0 and the name becomes "No One In Personal Space" if no one is next to BH + if (!this.testRequirements()) { + return false; + } + + return true; + }, + mbuff: 0, + obuff: 0, + abilityName: '', + + getAbilityName: function (abilityName) { + if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: Team.Enemy })) { + this.abilityName = 'No One In Personal Space'; + return this.abilityName; + } else { + this.abilityName = 'Enemy In Personal Space!'; + return this.abilityName; + } + }, - getBuff: function () { - //decides how many much the base value is modified by the buff, 50% if not upgraded and 100% if upgraded + getMovementBuff: function (mbuff) { + //decides how many much the base value (2) is modified by the buff, 50% if not upgraded and 100% if upgraded + if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: Team.Enemy })) { + this.mbuff = 0; + return this.mbuff; + } if (this.isUpgraded()) { - return 1; - } else return 0.5; + this.mbuff = 2; + return this.mbuff; + } + this.mbuff = 1; + return this.mbuff; }, - require: function () { - // Check requirements in activate() so the ability is always highlighted - return this.testRequirements(); + getOffenseBuff: function (obuff) { + //decides how many much the base value (12) is modified by the buff, 50% if not upgraded and 100% if upgraded + if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: Team.Enemy })) { + this.obuff = 0; + return this.obuff; + } + if (this.isUpgraded()) { + this.obuff = 12; + return this.obuff; + } + this.obuff = 6; + return this.obuff; }, activate: function () { - //check if there's any enemy next to Bounty Hunter - let hexesAllAround = this.creature.getHexMap(matrices.allaround1hex); - if (hexesAllAround.length < 1) { - return; + if (true) { + this.creature.replaceEffect( + new Effect( + this.getAbilityName(this.abilityName), //ability name + this.creature, //caster + this.creature, //target + '', //trigger + { + alterations: { + movement: this.getMovementBuff(this.mbuff), + offense: this.getOffenseBuff(this.obuff), + }, + stackable: false, + deleteTrigger: 'onEndPhase', + turnLifetime: 1, + }, + G, + ), + ); } - let target = hexesAllAround[0].creature; - if (!target) { - return; + }, + }, + + /** Second Ability: + * Sword Slitter + * Attacks adjacent enemy unit + * Does 15 slash + 10 pierce damage + */ + { + trigger: 'onQuery', + + _targetTeam: Team.Enemy, + + require: function () { + //checks if there is an enemy creature next to BH + if (!this.testRequirements()) { + return false; } - if (!isTeam(this.creature, target, Team.Enemy)) { - return; + if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: this._targetTeam })) { + return false; } + return true; + }, - this.end(); + //query(): + query: function () { + let ability = this; + let crea = this.creature; - this.creature.addEffect( - new Effect( - this._effectName, - this.creature, - this.creature, - '', + G.grid.queryCreature({ + fnOnConfirm: function () { + ability.animation(...arguments); + }, + team: this._targetTeam, + id: crea.id, + flipped: crea.player.flipped, + hexes: crea.adjacentHexes(1), + }); + }, + + //activate(): + activate: function (target) { + let targetOriginalHealth = target.health; + + let ability = this; + ability.end(); + G.Phaser.camera.shake(0.01, 150, true, G.Phaser.camera.SHAKE_HORIZONTAL, true); + + let damage = new Damage( + ability.creature, // Attacker + ability.damages, // Damage Type + 1, // Area + [], // Effects + G, + ); + target.takeDamage(damage); + /** damage dealt is og health - current health + * if current health is lower than damage dealt, + * and the ability is upgraded, + * make a second attack + */ + if (targetOriginalHealth - target.health >= target.health && this.isUpgraded()) { + target.takeDamage(damage); + } + }, + }, + + // Third Ability: Ground Ball + { + // Type : Can be "onQuery", "onStartPhase", "onDamage" + trigger: 'onQuery', + + _targetTeam: Team.Enemy, + + // require() : + require: function () { + if (!this.testRequirements()) { + return false; + } + + let bellowrow = matrices.bellowrow; + let straitrow = matrices.straitrow; + + let swine = this.creature; + let hexes = arrayUtils + .filterCreature( + G.grid.getHexMap(swine.x, swine.y - 2, 0, false, bellowrow), + true, + true, + swine.id, + swine.team, + ) + .concat( + arrayUtils.filterCreature( + G.grid.getHexMap(swine.x, swine.y, 0, false, straitrow), + true, + true, + swine.id, + swine.team, + ), + arrayUtils.filterCreature( + G.grid.getHexMap(swine.x, swine.y, 0, false, bellowrow), + true, + true, + swine.id, + swine.team, + ), + arrayUtils.filterCreature( + G.grid.getHexMap(swine.x, swine.y - 2, 0, true, bellowrow), + true, + true, + swine.id, + swine.team, + ), + arrayUtils.filterCreature( + G.grid.getHexMap(swine.x, swine.y, 0, true, straitrow), + true, + true, + swine.id, + swine.team, + ), + arrayUtils.filterCreature( + G.grid.getHexMap(swine.x, swine.y, 0, true, bellowrow), + true, + true, + swine.id, + swine.team, + ), + ); + if ( + !this.atLeastOneTarget(hexes, { + team: this._targetTeam, + }) + ) { + return false; + } + + return true; + }, + + // query() : + query: function () { + let bellowrow = matrices.bellowrow; + let straitrow = matrices.straitrow; + + let ability = this; + let swine = this.creature; + + let choices = [ + // Front + G.grid.getHexMap(swine.x, swine.y - 2, 0, false, bellowrow), + G.grid.getHexMap(swine.x, swine.y, 0, false, straitrow), + G.grid.getHexMap(swine.x, swine.y, 0, false, bellowrow), + // Behind + G.grid.getHexMap(swine.x, swine.y - 2, 0, true, bellowrow), + G.grid.getHexMap(swine.x, swine.y, 0, true, straitrow), + G.grid.getHexMap(swine.x, swine.y, 0, true, bellowrow), + ]; + + choices.forEach(function (choice) { + arrayUtils.filterCreature(choice, true, true, swine.id); + }); + + G.grid.queryChoice({ + fnOnConfirm: function () { + ability.animation(...arguments); + }, // fnOnConfirm + team: this._targetTeam, + requireCreature: 1, + id: swine.id, + flipped: swine.flipped, + choices: choices, + }); + }, + + // activate() : + activate: function (path) { + let ability = this; + ability.end(); + G.Phaser.camera.shake(0.01, 60, true, G.Phaser.camera.SHAKE_HORIZONTAL, true); + + let target = arrayUtils.last(path).creature; + + // If upgraded, hits will debuff target with -1 meditation + if (this.isUpgraded()) { + let effect = new Effect( + 'Ground Ball', + ability.creature, + target, + 'onDamage', { alterations: { - movement: this.creature.stats.movement * this.getBuff, - offense: this.creature.stats.offense * this.getBuff, + meditation: -1, }, - deleteTrigger: 'onStartPhase', - turnLifetime: 1, }, G, - ), + ); + target.addEffect(effect); + G.log('%CreatureName' + target.id + "%'s meditation is lowered by 1"); + } + + let damage = new Damage( + ability.creature, // Attacker + ability.damages, // Damage Type + 1, // Area + [], // Effects + G, ); + target.takeDamage(damage); + }, + }, + + // Fourth Ability: Mud Bath + { + // Type : Can be "onQuery", "onStartPhase", "onDamage" + trigger: 'onQuery', + + _energyNormal: 30, + _energySelfUpgraded: 10, + + require: function () { + // If ability is upgraded, self cast energy cost is less + if (this.isUpgraded()) { + this.requirements = { + energy: this._energySelfUpgraded, + }; + this.costs = { + energy: this._energySelfUpgraded, + }; + } else { + this.requirements = { + energy: this._energyNormal, + }; + this.costs = { + energy: this._energyNormal, + }; + } + return this.testRequirements(); + }, + + // query() : + query: function () { + let ability = this; + let swine = this.creature; + + // Check if the ability is upgraded because then the self cast energy cost is less + let selfOnly = this.isUpgraded() && this.creature.energy < this._energyNormal; + + let hexes = []; + if (!selfOnly) { + // Gather all the reachable hexes, including the current one + hexes = G.grid.getFlyingRange(swine.x, swine.y, 50, 1, 0); + } + hexes.push(G.grid.hexes[swine.y][swine.x]); + + G.grid.queryHexes({ + fnOnCancel: function () { + G.activeCreature.queryMove(); + }, + fnOnConfirm: function () { + ability.animation(...arguments); + }, + hexes: hexes, + hideNonTarget: true, + }); + }, + + // activate() : + activate: function (hex) { + let ability = this; + let swine = this.creature; + + // If upgraded and cast on self, cost is less + let isSelf = hex.x === swine.x && hex.y === swine.y; + if (this.isUpgraded() && isSelf) { + this.requirements = { + energy: this._energySelfUpgraded, + }; + this.costs = { + energy: this._energySelfUpgraded, + }; + } else { + this.requirements = { + energy: this._energyNormal, + }; + this.costs = { + energy: this._energyNormal, + }; + } + + ability.end(); + + let effects = [ + new Effect( + 'Slow Down', + ability.creature, + hex, + 'onStepIn', + { + requireFn: function () { + if (!this.trap.hex.creature) { + return false; + } + return this.trap.hex.creature.type != 'A1'; + }, + effectFn: function (effect, crea) { + crea.remainingMove--; + }, + }, + G, + ), + ]; + + hex.createTrap('mud-bath', effects, ability.creature.player); + G.soundsys.playSound(G.soundLoaded[7], G.soundsys.effectsGainNode); + // Trigger trap immediately if on self + if (isSelf) { + // onCreatureMove is Spa Goggles' trigger event + G.onCreatureMove(swine, hex); + } }, }, ]; diff --git a/src/data/units.json b/src/data/units.json index 6ac8c15db..e135a4ad4 100644 --- a/src/data/units.json +++ b/src/data/units.json @@ -93,7 +93,7 @@ { "id": 1, "name": "Bounty Hunter", - "playable": true, + "playable": false, "level": 2, "realm": "A", "size": 1, diff --git a/src/utility/matrices.js b/src/utility/matrices.js index bb68c1f4c..9063edf87 100644 --- a/src/utility/matrices.js +++ b/src/utility/matrices.js @@ -36,15 +36,6 @@ export const bellowrow = [ bellowrow.origin = [0, 0]; -export const allaround1hex = [ - [0, 0, 0, 0], - [0, 1, 1, 0], - [1, 0, 1, 0], //Origin line - [0, 1, 1, 0], -]; - -allaround1hex.origin = [2, 2]; - export const frontnback2hex = [ [0, 0, 0, 0], [0, 1, 0, 1], From d9758715177ab16eb4c3708dc26b0ec2d18c78d1 Mon Sep 17 00:00:00 2001 From: Dread Knight Date: Tue, 11 Apr 2023 16:54:45 +0300 Subject: [PATCH 5/5] comment consistency space after // and avoided specific values and names in case of future changes --- src/abilities/Bounty-Hunter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/abilities/Bounty-Hunter.js b/src/abilities/Bounty-Hunter.js index 7005a066e..ad8878749 100644 --- a/src/abilities/Bounty-Hunter.js +++ b/src/abilities/Bounty-Hunter.js @@ -50,7 +50,7 @@ export default (G) => { }, getMovementBuff: function (mbuff) { - //decides how many much the base value (2) is modified by the buff, 50% if not upgraded and 100% if upgraded + // Decides how much the base value is modified by the buff, 50% if not upgraded and 100% if upgraded if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: Team.Enemy })) { this.mbuff = 0; return this.mbuff; @@ -64,7 +64,7 @@ export default (G) => { }, getOffenseBuff: function (obuff) { - //decides how many much the base value (12) is modified by the buff, 50% if not upgraded and 100% if upgraded + // Decides how much the base value is modified by the buff, 50% if not upgraded and 100% if upgraded if (!this.atLeastOneTarget(this.creature.adjacentHexes(1), { team: Team.Enemy })) { this.obuff = 0; return this.obuff; @@ -81,10 +81,10 @@ export default (G) => { if (true) { this.creature.replaceEffect( new Effect( - this.getAbilityName(this.abilityName), //ability name - this.creature, //caster - this.creature, //target - '', //trigger + this.getAbilityName(this.abilityName), // Ability name + this.creature, // Caster + this.creature, // Target + '', // Trigger { alterations: { movement: this.getMovementBuff(this.mbuff), @@ -112,7 +112,7 @@ export default (G) => { _targetTeam: Team.Enemy, require: function () { - //checks if there is an enemy creature next to BH + // Checks if there is an enemy creature nearby if (!this.testRequirements()) { return false; }