Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix protect calculations #324

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arena/actions/__snapshots__/protect.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`protect should not get exp if protect enemy 1`] = `
"*corporis* пытался атаковать *quisquam*, но у него не получилось
_Защита_ *quisquam*: 📖43,*corporis*: 📖0"
_Защита_ *quisquam*: 📖33,*corporis*: 📖0"
`;

exports[`protect should protect player 1`] = `
Expand Down
6 changes: 2 additions & 4 deletions src/arena/actions/protect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ describe('protect', () => {

it('should protect player', () => {
game.players.players[0].proc = 1;
game.players.players[0].stats.set('pdef', 100);
game.players.players[1].proc = 0.1;
game.players.players[1].proc = 1;

protect.cast(game.players.players[0], game.players.players[0], game);
attack.cast(game.players.players[1], game.players.players[0], game);
Expand All @@ -45,8 +44,7 @@ describe('protect', () => {

it('should not get exp if protect enemy', () => {
game.players.players[0].proc = 1;
game.players.players[0].stats.set('pdef', 10);
game.players.players[1].proc = 0.1;
game.players.players[1].proc = 1;

protect.cast(game.players.players[0], game.players.players[0], game);
protect.cast(game.players.players[1], game.players.players[0], game);
Expand Down
5 changes: 2 additions & 3 deletions src/arena/actions/protect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ class Protect extends AffectableAction implements PreAffect {
const attackValue = initiator.stats.val('patk') * initiator.proc;
const protectValue = target.flags.isProtected.length > 0 ? target.stats.val('pdef') : 0.1;
const ratio = floatNumber(Math.round(attackValue / protectValue));
console.log('at', ratio);

const randomValue = MiscService.rndm('1d100');
const chance = 20 * ratio + 50;
const chance = Math.round(Math.sqrt(ratio) + (10 * ratio) + 5);
Copy link
Collaborator

Choose a reason for hiding this comment

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

При соотношение 1:1 мы получим 16% пробития :/
При 2:1 = 29

Один фиг формула выглядит кривой :)

const result = chance > randomValue;
console.log('chance', chance, 'random', randomValue, 'result', result);

Expand Down Expand Up @@ -82,7 +81,7 @@ class Protect extends AffectableAction implements PreAffect {
}

const protect = Math.floor(flag.val * 100) / pdef;
const exp = Math.round(expMultiplier * 0.8 * protect);
const exp = Math.round(expMultiplier * 0.08 * protect);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Вроде договаривались про 0.4, или много получилось ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

С 0.08 получается 40, 0.4 будет 200 соответственно для игрока первого уровня

Copy link
Collaborator

Choose a reason for hiding this comment

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

Но у игрока первого уровня нет стены :)

defender.stats.up('exp', exp);

return {
Expand Down
Loading