Skip to content

Commit

Permalink
Item update (#39)
Browse files Browse the repository at this point in the history
* add new items

* item name

* change item description

* remove old items

* random fossil evolution

* rework item && create new bot and detailled stat version

* upgrade to 1.6

* implement stones

* first item impl

* bright powder

* spelldamage critdamage delta orb

* mana scarf

* smoke ball

* xray vosion

* razor fang

* LEFTOVERS: 'During  the combat, the holder attack heals adjacent allies for 3 health point',
  CHOICE_SCARF: 'The holder basic attack hit a second adjacent ennemy for 75% of holder damage',
  FIRE_GEM: 'The holders Abilities and attacks do 20% bonus damage. If the target has more than 200 maximum Health, the bonus increases to 60%.',
  DEFENSIVE_RIBBON: 'When the holder takes damage, they gain attack damage, 1 defense and 1 special defense. Stacks up to 5 times',
  WONDER_BOX: 'At the beginning of each battle phase, the holder equips 2 temporary items',
  RUNE_PROTECT: 'When combat begins, the holder and all allies whithin 1 hex in the same row gain a shield that block the damage and effects of the first ennemy ability',

* end of item impl

* basic item propositions

* item rework

* refactoring

* item recipe

* finish item impl

* wiki items

* fix moomoo milk

* wiki types

* item check

* faq

* add item cheat sheet

* update dependency

* fix win count
  • Loading branch information
keldaan-ag authored Feb 22, 2022
1 parent 3d19418 commit 0087380
Show file tree
Hide file tree
Showing 185 changed files with 6,539 additions and 4,441 deletions.
135 changes: 72 additions & 63 deletions app/core/attack-strategy.js

Large diffs are not rendered by default.

70 changes: 51 additions & 19 deletions app/core/attacking-state.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {STATE_TYPE, EFFECTS, ITEMS, ATTACK_TYPE, CLIMATE, ORIENTATION} = require('../models/enum');
const {STATE_TYPE, EFFECTS, ATTACK_TYPE, CLIMATE, ORIENTATION, ITEM} = require('../models/enum');
const PokemonState = require('./pokemon-state');

class AttackingState extends PokemonState {
Expand Down Expand Up @@ -32,6 +32,10 @@ class AttackingState extends PokemonState {
pokemon.targetY = coordinates[1];
const target = board.getValue(coordinates[0], coordinates[1]);
if (target && !pokemon.status.sleep && !pokemon.status.freeze) {
if (pokemon.items.has(ITEM.UPGRADE)) {
pokemon.handleAttackSpeed(6);
}

if (climate == CLIMATE.SNOW) {
let freezeChance = 0;
if (pokemon.effects.includes(EFFECTS.SNOW)) {
Expand All @@ -44,11 +48,6 @@ class AttackingState extends PokemonState {
target.status.triggerFreeze(2000);
}
}
if (pokemon.items.count(ITEMS.ICY_ROCK) != 0) {
if (Math.random() > 0.9) {
target.status.triggerFreeze(2000);
}
}
let poisonChance = 0;
if (pokemon.effects.includes(EFFECTS.POISON_GAS)) {
poisonChance += 0.1;
Expand All @@ -58,7 +57,7 @@ class AttackingState extends PokemonState {
}
if (poisonChance != 0) {
if (Math.random() > poisonChance) {
target.status.triggerPoison(2000);
target.status.triggerPoison(2000, target);
}
}
if (pokemon.effects.includes(EFFECTS.CURSE) || pokemon.effects.includes(EFFECTS.PHANTOM_FORCE)) {
Expand All @@ -77,9 +76,9 @@ class AttackingState extends PokemonState {
}
// console.log(`pokemon attack from (${pokemon.positionX},${pokemon.positionY}) to (${pokemon.targetX},${pokemon.targetY}), orientation: ${pokemon.orientation}`);
let damage;
let attackType = pokemon.attackType;
const attackType = pokemon.attackType;

if (Math.random() * 100 < pokemon.critChance) {
if (Math.random() * 100 < pokemon.critChance && target && target.items.has(ITEM.ROCKY_HELMET)) {
if (pokemon.effects.includes(EFFECTS.FAIRY_WIND) || pokemon.effects.includes(EFFECTS.STRANGE_STEAM) || pokemon.effects.includes(EFFECTS.AROMATIC_MIST)) {
let d = 0;
if (pokemon.effects.includes(EFFECTS.AROMATIC_MIST)) {
Expand Down Expand Up @@ -118,26 +117,59 @@ class AttackingState extends PokemonState {
}
damage = Math.round(pokemon.atk * pokemon.critDamage);
target.count.crit ++;
if (pokemon.items.count(ITEMS.RAZOR_CLAW) != 0) {
attackType = ATTACK_TYPE.TRUE;
}
} else {
damage = pokemon.atk;
}

if (target.items.count(ITEMS.ROCKY_HELMET) != 0) {
pokemon.handleDamage(Math.ceil(pokemon.hp * 0.04) * target.items.count(ITEMS.ROCKY_HELMET), board, ATTACK_TYPE.PHYSICAL, target);
const victim = target.handleDamage(damage, board, attackType, pokemon);

if (pokemon.items.has(ITEM.BLUE_ORB)) {
pokemon.count.staticHolderCount ++;
if (pokemon.count.staticHolderCount > 3) {
pokemon.count.staticHolderCount = 0;
let c = 4;
board.forEach((x, y, tg) => {
if (tg && pokemon.team != tg.team) {
tg.count.staticCount ++;
tg.handleDamage(8, board, ATTACK_TYPE.SPECIAL, pokemon);
c --;
}
});
}
}

if (pokemon.items.count(ITEMS.LIFE_ORB) != 0) {
pokemon.handleDamage(Math.ceil(pokemon.hp * 0.05) * pokemon.items.count(ITEMS.LIFE_ORB), board, ATTACK_TYPE.TRUE, pokemon);
if (target && target.items.has(ITEM.SMOKE_BALL)) {
pokemon.status.triggerSmoke(5000, pokemon);
}

if (pokemon.items.count(ITEMS.SHELL_BELL) != 0) {
pokemon.handleHeal(Math.ceil(damage / 10) * pokemon.items.count(ITEMS.SHELL_BELL));
if (target && pokemon.items.has(ITEM.RAZOR_FANG)) {
target.status.triggerArmorReduction(5000);
}

const victim = target.handleDamage(damage, board, attackType, pokemon);
if (pokemon.items.has(ITEM.CHOICE_SCARF)) {
const cells = board.getAdjacentCells(target.positionX, target.positionY);
let targetCount = 1;
cells.forEach((cell) => {
if (cell.value && pokemon.team != cell.value.team && targetCount > 0) {
cell.value.handleDamage(Math.ceil(0.75 * damage), board, attackType, pokemon);
targetCount --;
}
});
}

if (pokemon.items.has(ITEM.LEFTOVERS)) {
const cells = board.getAdjacentCells(pokemon.positionX, pokemon.positionY);
pokemon.handleHeal(3);
cells.forEach((cell) => {
if (cell.value && pokemon.team == cell.value.team) {
cell.value.handleHeal(3);
}
});
}

if (pokemon.items.has(ITEM.MANA_SCARF)) {
pokemon.setMana(pokemon.mana + 8);
}

if (victim && pokemon.effects.includes(EFFECTS.BRUTAL_SWING)) {
pokemon.handleHeal(pokemon.hp);
Expand Down
4 changes: 3 additions & 1 deletion app/core/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class Bot {
pkm.positionY = stepTeam.board[i].y;
if (stepTeam.board[i].items) {
stepTeam.board[i].items.forEach((item)=>{
pkm.items.add(item);
if (!pkm.items.has(item)) {
pkm.items.add(item);
}
});
}
this.player.board.set(pkm.id, pkm);
Expand Down
44 changes: 35 additions & 9 deletions app/core/pokemon-entity.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const schema = require('@colyseus/schema');
const STATE_TYPE = require('../models/enum').STATE_TYPE;
const ORIENTATION = require('../models/enum').ORIENTATION;
const {STATE_TYPE, ORIENTATION, ITEM} = require('../models/enum');
const MovingState = require('./moving-state');
const AttackingState = require('./attacking-state');
const uniqid = require('uniqid');
const Items = require('../models/colyseus-models/items');
const Status = require('../models/colyseus-models/status');
const Count = require('../models/colyseus-models/count');
const SetSchema = schema.SetSchema;
const ArraySchema = schema.ArraySchema;
const PokemonFactory = require('../models/pokemon-factory');

Expand All @@ -16,7 +15,10 @@ class PokemonEntity extends schema.Schema {

this.state = new MovingState();
this.effects = new ArraySchema();
this.items = new Items(pokemon.items);
this.items = new SetSchema();
pokemon.items.forEach((it) => {
this.items.add(it);
});
this.status = new Status();
this.count = new Count();
this.simulation = simulation;
Expand Down Expand Up @@ -57,10 +59,11 @@ class PokemonEntity extends schema.Schema {
types: [],
damageDone: 0,
stars: pokemon.stars,
skill: pokemon.skill
skill: pokemon.skill,
critDamage: 2,
spellDamage: 0
}
);
this.critDamage = 2;
this.dodge = 0;

pokemon.types.forEach((type) => {
Expand All @@ -71,7 +74,7 @@ class PokemonEntity extends schema.Schema {
update(dt, board, climate) {
const updateEffects = this.state.update(this, dt, board, climate);
if (updateEffects) {
this.simulation.applyItemsEffects(this, this.types);
this.simulation.applyItemsEffects(this);
}
}

Expand All @@ -88,6 +91,27 @@ class PokemonEntity extends schema.Schema {
return this.state.handleDamage(this, damage, board, attackType, attacker);
}

handleSpellDamage(damage, board, attackType, attacker) {
let spellDamage = damage + attacker.spellDamage;
if (attacker && 0.2 * attacker.items.has(ITEM.REAPER_CLOTH) > Math.random()) {
spellDamage *= 2;
this.count.crit ++;
}
if (attacker && attacker.items.has(ITEM.POKEMONOMICON)) {
this.status.triggerBurn(3000, this);
this.status.triggerWound(3000);
}
if (attacker && attacker.items.has(ITEM.SHELL_BELL)) {
attacker.handleHeal(0.4 * damage);
}
if (this.status.runeProtect) {
this.status.disableRuneProtect();
return;
} else {
return this.state.handleDamage(this, spellDamage, board, attackType, attacker);
}
}

handleHeal(heal) {
return this.state.handleHeal(this, heal);
}
Expand Down Expand Up @@ -155,11 +179,13 @@ schema.defineTypes(PokemonEntity, {
rarity: 'string',
name: 'string',
effects: ['string'],
items: Items,
items: {set: 'string'},
stars: 'uint8',
skill: 'string',
status: Status,
count: Count
count: Count,
critDamage: 'float32',
spellDamage: 'uint8'
});

module.exports = PokemonEntity;
Loading

0 comments on commit 0087380

Please sign in to comment.