Skip to content

Commit

Permalink
nerf bug
Browse files Browse the repository at this point in the history
    buff field
    nerf poison
    remove message limit per day
    meloetta icon
    remove bad words
    persistent dps meter
    better dps meter
    set life 0 death animation
    death animation
    add more alternative tileset
    fix night slash
    fix monster
    alolan marowak quadruple type
    king shield buff
    scyther bug flying
    fix description
    human && monster rework
    water rework
    ground rework
    charmander fire dragon
    kyurem ice dragon
    each map hat its own music
    remove double
    cdn load music
    new sound system
    nerf gastly
    rework of ghost synergy
    remove effect number
    remove old tilemaps
    multiplier x3 >25, x5 >30, x8 >35
    new map integration
    add arena into map
    fix poison maze
    add simplex noise feature
    add terrain generation
    working random version
    test
    tileset
    tileset mapping
    add all tilesets
    add metadata for 50 tilesets
  • Loading branch information
keldaan-ag committed Feb 6, 2022
1 parent 6af9ae5 commit bcc8266
Show file tree
Hide file tree
Showing 261 changed files with 2,151 additions and 1,822 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ app/public/dist/**/*.js
/app/public/dist/assets/tiles/sleepBackgroundMirror.png
/app/public/dist/index.js.LICENSE.txt
/db-commands/old-statistic.js
/app/public/dist/assets/tilesets/*.png
/db-commands/*.sh
/tests/render/*.png
/tests/samples/*.json
28 changes: 20 additions & 8 deletions app/core/attack-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ class AttackStrategy {
process(pokemon, state, board, target) {
pokemon.setMana(0);
pokemon.count.ult += 1;
if (pokemon.types.includes(TYPE.MONSTER) && pokemon.shield <= 0) {
let shield = 0;
if (pokemon.effects.includes(EFFECTS.PURSUIT)) {
shield = Math.floor(pokemon.hp * 0.2);
} else if (pokemon.effects.includes(EFFECTS.BRUTAL_SWING)) {
shield = Math.floor(pokemon.hp * 0.3);
} else if (pokemon.effects.includes(EFFECTS.POWER_TRIP)) {
shield = Math.floor(pokemon.hp * 0.4);
}
if (shield > 0 && !pokemon.status.temporaryShield) {
pokemon.status.triggerShield(4000);
pokemon.shield = shield;
}
}
if (pokemon.types.includes(TYPE.SOUND)) {
let atk = 0;
if (pokemon.effects.includes(EFFECTS.LARGO)) {
Expand Down Expand Up @@ -34,13 +48,13 @@ class KingShieldStrategy extends AttackStrategy {
let timer = 0;
switch (pokemon.stars) {
case 1:
timer = 500;
timer = 750;
break;
case 2:
timer = 1000;
timer = 1500;
break;
case 3:
timer = 2000;
timer = 3000;
break;
default:
break;
Expand Down Expand Up @@ -1570,11 +1584,9 @@ class NightSlashStrategy extends AttackStrategy {

target.handleDamage(damage, board, ATTACK_TYPE.SPECIAL, pokemon);

const cells = board.getAdjacentCells(pokemon.positionX, pokemon.positionY);

cells.forEach((cell) => {
if (cell.value && pokemon.team != cell.value.team) {
cell.value.def = Math.max(0, cell.value.def - 1);
board.forEach((x, y, v) => {
if (v && pokemon.team != v.team) {
v.def = Math.max(0, v.def - 1);
}
});
}
Expand Down
11 changes: 4 additions & 7 deletions app/core/attacking-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ class AttackingState extends PokemonState {
}
let poisonChance = 0;
if (pokemon.effects.includes(EFFECTS.POISON_GAS)) {
poisonChance += 0.2;
poisonChance += 0.1;
}
if (pokemon.effects.includes(EFFECTS.TOXIC)) {
poisonChance += 0.5;
poisonChance += 0.3;
}
if (poisonChance != 0) {
if (Math.random() > poisonChance) {
target.status.triggerPoison(2000);
}
}
if (pokemon.effects.includes(EFFECTS.CURSE)) {
target.status.triggerSilence(2000);
if (pokemon.effects.includes(EFFECTS.CURSE) || pokemon.effects.includes(EFFECTS.PHANTOM_FORCE)) {
target.status.triggerSilence(3000);
}
if (pokemon.effects.includes(EFFECTS.REVENGE)) {
pokemon.setMana(pokemon.mana + 5);
Expand Down Expand Up @@ -125,9 +125,6 @@ class AttackingState extends PokemonState {
damage = pokemon.atk;
}

if (pokemon.effects.includes(EFFECTS.PHANTOM_FORCE)) {
attackType = ATTACK_TYPE.TRUE;
}
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);
}
Expand Down
114 changes: 114 additions & 0 deletions app/core/design.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
const {TERRAIN} = require('../models/enum');
const Mask = require('./mask');
const Terrain = require('./terrain');
const Tileset = require('./tileset');

class Design {
constructor(id, frequency, persistance) {
this.id = id;
this.terrain = [];
this.bitmask = [];
this.tilemap = [];
this.width = 85;
this.height = 43;
this.frequency = frequency;
this.persistance = persistance;
this.tileset = new Tileset(this.id);
this.minArena = [26, 4];
this.maxArena = [58, 35];
this.leftBorder = [27, 31];
this.rightBorder = [57, 31];
this.create();
}

create() {
this.generateTerrain();
this.generateMask();
this.generateTilemap();
}

generateTerrain() {
const t = new Terrain(this.width, this.height, this.frequency, this.persistance);
const generation = t.terrain;

for (let i = 0; i < this.height; i++) {
const row = [];
for (let j = 0; j < this.width; j++) {
const v = generation[i][j];
if (v > 0.66) {
row.push(TERRAIN.WALL);
} else if (v>0.33) {
row.push(TERRAIN.GROUND);
} else {
row.push(TERRAIN.WATER);
}
}
this.terrain.push(row);
}

for (let i = this.minArena[0]; i < this.maxArena[0]; i++) {
for (let j = this.minArena[1]; j < this.maxArena[1]; j++) {
this.terrain[j][i] = TERRAIN.GROUND;
}
}

for (let i = this.leftBorder[0]; i < this.rightBorder[0]; i++) {
this.terrain[this.leftBorder[1]][i] = TERRAIN.WALL;
}
}

generateMask() {
const mask = new Mask();
for (let i = 0; i < this.height; i++) {
const row = [];
for (let j = 0; j < this.width; j++) {
row.push(mask.mask8bits(this.terrain, i, j));
}
this.bitmask.push(row);
}
}

generateTilemap() {
for (let i = 0; i < this.height; i++) {
for (let j = 0; j < this.width; j++) {
const tileID = this.tileset.getTilemapId(this.terrain[i][j], this.bitmask[i][j]);
// console.log(tileID, ',');
this.tilemap.push(tileID);
}
}
}

exportToTiled() {
return {
compressionlevel: -1,
height: this.height,
infinite: false,
layers: [
{
data: this.tilemap,
height: this.height,
id: 1,
name: 'World',
opacity: 1,
type: 'tilelayer',
visible: true,
width: this.width,
x: 0,
y: 0
}],
nextlayerid: 6,
nextobjectid: 1,
orientation: 'orthogonal',
renderorder: 'right-down',
tiledversion: '1.7.2',
tileheight: 24,
tilesets: [this.tileset.exportToTiled()],
tilewidth: 24,
type: 'map',
version: '1.6',
width: this.width
};
}
};

module.exports = Design;
22 changes: 22 additions & 0 deletions app/core/mask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const {ID_TABLE} = require('../models/enum');

class Mask {
mask8bits(matrix, row, col) {
let m = 0; const v = matrix[row][col];
m |= this.eq(matrix, row - 1, col, v) << 0;
m |= this.eq(matrix, row, col + 1, v) << 1;
m |= this.eq(matrix, row + 1, col, v) << 2;
m |= this.eq(matrix, row, col - 1, v) << 3;
m |= (m & 0b0011) == 0b0011 ? this.eq(matrix, row - 1, col + 1, v) << 4 : 0;
m |= (m & 0b0110) == 0b0110 ? this.eq(matrix, row + 1, col + 1, v) << 5 : 0;
m |= (m & 0b1100) == 0b1100 ? this.eq(matrix, row + 1, col - 1, v) << 6 : 0;
m |= (m & 0b1001) == 0b1001 ? this.eq(matrix, row - 1, col - 1, v) << 7 : 0;
return ID_TABLE[m];
}

eq(m, r, c, v) {
return (r >= 0 && r < m.length && c >= 0 && c < m[r].length && m[r][c] == v) ? 1 : 0;
}
}

module.exports = Mask;
5 changes: 5 additions & 0 deletions app/core/pokemon-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class PokemonEntity extends schema.Schema {
}
);
this.critDamage = 2;
this.dodge = 0;

pokemon.types.forEach((type) => {
this.types.push(type);
Expand Down Expand Up @@ -120,6 +121,10 @@ class PokemonEntity extends schema.Schema {
this.critChance = 100;
}
}

addDodgeChance(value) {
this.dodge = Math.min(0.9, this.dodge + value);
}
}

schema.defineTypes(PokemonEntity, {
Expand Down
64 changes: 52 additions & 12 deletions app/core/pokemon-state.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {EFFECTS, ATTACK_TYPE, TYPE, CLIMATE, ITEMS, PKM, FLYING_PROTECT_THRESHOLD} = require('../models/enum');
const {EFFECTS, ATTACK_TYPE, TYPE, ITEMS, PKM, FLYING_PROTECT_THRESHOLD} = require('../models/enum');
const PokemonFactory = require('../models/pokemon-factory');

class PokemonState {
Expand Down Expand Up @@ -40,7 +40,12 @@ class PokemonState {
// console.log(`error calculating damage, damage: ${damage}, defenseur: ${pokemon.name}, attaquant: ${attacker.name}, attack type: ${attackType}, defense : ${pokemon.def}, spedefense: ${pokemon.speDef}, life: ${pokemon.life}`);
}

if (attacker && attacker.team == 0) {
if (pokemon.dodge > Math.random()) {
reducedDamage = 0;
pokemon.count.dodgeCount += 1;
}

if (attacker && reducedDamage > 0) {
attacker.damageDone += reducedDamage;
}
let residualDamage = reducedDamage;
Expand Down Expand Up @@ -85,6 +90,17 @@ class PokemonState {

if (attacker) {
attacker.setMana(attacker.mana + 5);
if (attacker.effects.includes(EFFECTS.CALM_MIND) || attacker.effects.includes(EFFECTS.FOCUS_ENERGY) || attacker.effects.includes(EFFECTS.MEDITATE)) {
let lifesteal = 0;
if (attacker.effects.includes(EFFECTS.MEDITATE)) {
lifesteal = 0.15;
} else if (attacker.effects.includes(EFFECTS.FOCUS_ENERGY)) {
lifesteal = 0.3;
} else if (attacker.effects.includes(EFFECTS.CALM_MIND)) {
lifesteal = 0.6;
}
attacker.handleHeal(Math.floor(lifesteal * residualDamage));
}
}

if (!pokemon.life || pokemon.life <= 0) {
Expand All @@ -103,23 +119,23 @@ class PokemonState {
pokemon.status.resurection = false;
pokemon.life = pokemon.hp;
} else {
const isWorkUp = pokemon.effects.includes(EFFECTS.WORK_UP);
const isWorkUp = pokemon.effects.includes(EFFECTS.BULK_UP);
const isRage = pokemon.effects.includes(EFFECTS.RAGE);
const isAngerPoint = pokemon.effects.includes(EFFECTS.ANGER_POINT);

if (isWorkUp || isRage || isAngerPoint) {
let boost = 0;
if (isWorkUp) {
boost = 20;
} else if (isRage) {
boost = 30;
} else if (isRage) {
boost = 40;
} else if (isAngerPoint) {
boost = 50;
boost = 60;
}
board.forEach((r, c, value) => {
if (value !== undefined && value.team == pokemon.team && value.types.includes(TYPE.FIELD)) {
value.count.fieldCount ++;
value.handleHeal(0.2 * value.hp);
value.handleHeal(boost / 100 * value.hp);
value.handleAttackSpeed(boost);
}
});
Expand Down Expand Up @@ -156,6 +172,31 @@ class PokemonState {

update(pokemon, dt, board, climate) {
let updateEffects = false;
if (pokemon.effects.includes(EFFECTS.SHORE_UP) || pokemon.effects.includes(EFFECTS.ROTOTILLER) || pokemon.effects.includes(EFFECTS.SANDSTORM)) {
if (pokemon.growGroundTimer !== undefined && pokemon.count.growGroundCount <5) {
pokemon.growGroundTimer -= dt;
if (pokemon.growGroundTimer <= 0) {
pokemon.growGroundTimer = 2000;
pokemon.count.growGroundCount += 1;
if (pokemon.effects.includes(EFFECTS.SHORE_UP)) {
pokemon.def += 1;
pokemon.speDef += 1;
pokemon.atk += 1;
} else if (pokemon.effects.includes(EFFECTS.ROTOTILLER)) {
pokemon.def += 2;
pokemon.speDef += 2;
pokemon.atk += 2;
} else if (pokemon.effects.includes(EFFECTS.SANDSTORM)) {
pokemon.def += 3;
pokemon.speDef += 3;
pokemon.atk += 3;
}
}
} else {
pokemon.growGroundTimer = 2000;
}
}

if (pokemon.status.burn) {
pokemon.status.updateBurn(dt);
}
Expand Down Expand Up @@ -188,6 +229,10 @@ class PokemonState {
pokemon.status.updateWound(dt);
}

if (pokemon.status.temporaryShield) {
pokemon.status.updateShield(dt, pokemon);
}

if (pokemon.manaCooldown <= 0) {
pokemon.setMana(pokemon.mana + 10);

Expand Down Expand Up @@ -256,11 +301,6 @@ class PokemonState {
this.handleDamage(pokemon, Math.ceil(pokemon.hp *0.15), board, ATTACK_TYPE.TRUE);
}

if (climate == CLIMATE.SANDSTORM) {
if (pokemon.effects.includes(EFFECTS.SANDSTORM)) {
this.handleDamage(pokemon, Math.ceil(pokemon.hp / 20), board, ATTACK_TYPE.TRUE);
}
}
if (pokemon.effects.includes(EFFECTS.BLAZE)) {
pokemon.atk += 1;
}
Expand Down
Loading

0 comments on commit bcc8266

Please sign in to comment.