Skip to content

Commit

Permalink
👔 Updated battle formula to fix defence/generals + increase HP
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasGruber committed Aug 18, 2023
1 parent 68d2094 commit b8af5e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
9 changes: 4 additions & 5 deletions app/src/libs/combat/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ export const COMBAT_HEIGHT = 4;
export const COMBAT_SECONDS = 30;
export const COMBAT_LOBBY_SECONDS = 20;

export const LVL_SCALING = 1.75;
export const EXP_SCALING = 0.39;
export const DMG_SCALING = 0.8;
export const LVL_SCALING = 0.25;
export const EXP_SCALING = 0.5;
export const DMG_SCALING = 1;
export const POWER_SCALING = 0.01;
export const DMG_BASE = 8;
export const UNDERDOG = 3;
export const DMG_BASE = 10;

/**
* Which user state is public
Expand Down
7 changes: 3 additions & 4 deletions app/src/libs/combat/tags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BattleUserState, Consequence, ReturnedBattle } from "./types";
import type { GroundEffect, UserEffect, ActionEffect } from "./types";
import { LVL_SCALING, EXP_SCALING, DMG_SCALING, POWER_SCALING } from "./constants";
import { DMG_BASE, UNDERDOG } from "./constants";
import { DMG_BASE } from "./constants";
import { shouldApplyEffectTimes } from "./util";
import { nanoid } from "nanoid";

Expand Down Expand Up @@ -313,9 +313,8 @@ export const updateStatUsage = (

/** Function used for scaling two attributes against each other, used e.g. in damage calculation */
const powerEffect = (attack: number, defence: number) => {
const scaledDefence = Math.pow(defence, UNDERDOG);
const statRatio = Math.pow(attack / scaledDefence, LVL_SCALING);
return DMG_BASE + statRatio + Math.pow(attack, EXP_SCALING);
const statRatio = Math.pow(attack / defence, LVL_SCALING);
return DMG_BASE + statRatio * Math.pow(attack, EXP_SCALING);
};

/** Calculate damage effect on target */
Expand Down
2 changes: 1 addition & 1 deletion app/src/libs/hospital/hospital.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { secondsPassed, secondsFromNow } from "../../utils/time";
import type { UserData } from "../../../drizzle/schema";

export const calcHealCost = (user: UserData) => {
return (user.maxHealth - user.curHealth) / 4;
return (user.maxHealth - user.curHealth) / 10;
};

export const healSecondsLeft = (user: UserData) => {
Expand Down
6 changes: 3 additions & 3 deletions app/src/libs/profile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const HP_PER_LVL = 10;
export const SP_PER_LVL = 10;
export const CP_PER_LVL = 10;
export const HP_PER_LVL = 50;
export const SP_PER_LVL = 50;
export const CP_PER_LVL = 50;

export function calcLevelRequirements(level: number): number {
const prevLvl = level - 1;
Expand Down

1 comment on commit b8af5e9

@vercel
Copy link

@vercel vercel bot commented on b8af5e9 Aug 18, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.