Skip to content

Commit 1d59fe7

Browse files
authored
feat: add sweepingBlow passive (#556)
1 parent 08b8c79 commit 1d59fe7

34 files changed

Lines changed: 240 additions & 80 deletions

server/arena/Constuructors/BaseAction.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ export abstract class BaseAction {
6767
};
6868
}
6969

70-
getSuccessResult({ initiator, target } = this.params): SuccessArgs {
70+
getSuccessResult({ initiator, target, status } = this.context): SuccessArgs {
7171
return {
72-
exp: this.status.exp,
72+
exp: status.exp,
7373
action: this.displayName,
7474
actionType: this.actionType,
7575
target,
7676
initiator,
77-
effect: floatNumber(this.status.effect),
77+
effect: floatNumber(status.effect),
7878
hp: target.stats.val('hp'),
7979
effectType: this.effectType,
8080
orderType: this.orderType,
81-
expArr: this.status.expArr,
82-
affects: this.status.affects,
81+
expArr: status.expArr,
82+
affects: status.affects,
8383
// @ts-expect-error todo вынести кастомные сообщения в отдельный сервис
8484
msg: this.customMessage?.bind(this),
8585
};
@@ -110,12 +110,12 @@ export abstract class BaseAction {
110110
}
111111
}
112112

113-
next({ initiator, target, game } = this.params): void {
114-
const result = this.getSuccessResult({ initiator, target, game });
113+
next(context = this.context): void {
114+
const result = this.getSuccessResult(context);
115115
this.giveExp(result);
116116

117117
if (!this.isAffect) {
118-
game.recordOrderResult(result);
118+
context.game.recordOrderResult(result);
119119
}
120120
}
121121

server/arena/Constuructors/BaseActionContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export class BaseActionContext {
3636
this.params.target = target;
3737
}
3838

39-
addAffect(action: BaseAction, params = this.params) {
40-
const result = action.getSuccessResult(params);
39+
addAffect(action: BaseAction, ctx = this) {
40+
const result = action.getSuccessResult(ctx);
4141
this.rootCtx.status.affects.push(result);
4242

4343
return result;

server/arena/Constuructors/LongDmgMagicConstructor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BaseActionParams } from '@/arena/Constuructors/BaseAction';
1+
import type { BaseActionContext } from '@/arena/Constuructors/BaseAction';
22
import type Game from '../GameService';
33
import type { Player } from '../PlayersService';
44
import { DmgMagic } from './DmgMagicConstructor';
@@ -25,7 +25,7 @@ export abstract class LongDmgMagic extends DmgMagic {
2525
this.checkChance();
2626
this.run(initiator, target, game); // вызов кастомного обработчика
2727
this.calculateExp();
28-
this.next({ initiator, target, game });
28+
this.next(this.context);
2929
} catch (failMsg) {
3030
if (this.isAffect) {
3131
throw failMsg;
@@ -36,9 +36,9 @@ export abstract class LongDmgMagic extends DmgMagic {
3636
}
3737
}
3838

39-
override getSuccessResult(params?: BaseActionParams): SuccessArgs {
39+
override getSuccessResult(ctx?: BaseActionContext): SuccessArgs {
4040
return {
41-
...super.getSuccessResult(params),
41+
...super.getSuccessResult(ctx),
4242
duration: this.duration,
4343
};
4444
}

server/arena/Constuructors/LongMagicConstructor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ActionType } from '@fwo/shared';
2-
import type { BaseActionParams } from '@/arena/Constuructors/BaseAction';
2+
import type { BaseActionContext } from '@/arena/Constuructors/BaseAction';
33
import type { SuccessArgs } from '@/arena/Constuructors/types';
44
import type Game from '../GameService';
55
import type { Player } from '../PlayersService';
@@ -37,7 +37,7 @@ export abstract class LongMagic extends CommonMagic {
3737
this.onBeforeRun();
3838
this.run(initiator, target, game); // вызов кастомного обработчика
3939
this.calculateExp();
40-
this.next({ initiator, target, game });
40+
this.next(this.context);
4141
} catch (e) {
4242
if (this.isAffect) {
4343
throw e;
@@ -49,9 +49,9 @@ export abstract class LongMagic extends CommonMagic {
4949
}
5050
}
5151

52-
override getSuccessResult(params?: BaseActionParams): SuccessArgs {
52+
override getSuccessResult(context?: BaseActionContext): SuccessArgs {
5353
return {
54-
...super.getSuccessResult(params),
54+
...super.getSuccessResult(context),
5555
duration: this.duration,
5656
};
5757
}

server/arena/Constuructors/PhysConstructor.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,19 @@ export default abstract class PhysConstructor extends BaseAction {
7373
this.status.effect = floatNumber(hit * initiator.proc);
7474
}
7575

76-
/**
77-
* Рассчитываем полученный exp
78-
*/
79-
calculateExp({ initiator, target } = this.params) {
76+
getEffectExp({ initiator, target } = this.params, effect: number) {
8077
const effects = initiator.affects.getEffectsByAction('glitch');
8178
if (initiator.isAlly(target) && !effects.length) {
82-
this.status.exp = 0;
79+
return 0;
8380
} else {
84-
this.status.exp = Math.round(this.status.effect * 8);
81+
return Math.round(effect * 8);
8582
}
8683
}
84+
85+
/**
86+
* Рассчитываем полученный exp
87+
*/
88+
calculateExp(params = this.params) {
89+
this.status.exp = this.getEffectExp(params, this.status.effect);
90+
}
8791
}

server/arena/Constuructors/ProtectConstructor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,24 @@ export abstract class ProtectConstructor extends BaseAction {
8181
}
8282

8383
this.reset();
84-
const { initiator, target, game } = ctx.params;
84+
const { initiator, target, game } = ctx;
8585
this.createContext(initiator, target, game);
8686

87-
const protectors = this.getTargetProtectors(ctx.params);
87+
const protectors = this.getTargetProtectors(ctx);
8888
if (!protectors.length) {
8989
return;
9090
}
9191

9292
const protect = protectors.reduce((acc, { value = 0 }) => acc + value, 0);
93-
const chance = this.getProtectChance(ctx.params, protect);
93+
const chance = this.getProtectChance(ctx, protect);
9494

9595
const ratio = Math.min(chance / 100, 0.5);
9696

9797
if (MiscService.chance(chance)) {
9898
this.calculateExp({ initiator, target, game }, ctx.status.effect);
9999
this.reduceProtection(ratio);
100100

101-
throw new CastError(this.getSuccessResult({ initiator, target, game }));
101+
throw new CastError(this.getSuccessResult(this.context));
102102
} else {
103103
this.reduceProtection(ratio);
104104
}

server/arena/LogService/utils/format-cause.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { formatAction } from './format-action';
44
import { formatExp } from './format-exp';
55

66
export function formatCause(cause: SuccessArgs) {
7+
console.log(cause.actionType, cause.action, cause.msg);
78
switch (cause.actionType) {
89
case 'dodge':
910
case 'skill':

server/arena/LogService/utils/format-exp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { brackets } from '@/utils/formatString';
33
import { getDamageTypeIcon } from '@/utils/icons';
44

55
export function formatExp(args: SuccessArgs): string {
6+
console.log(args.action);
67
const exp = args.initiator.isBot ? '' : `📖${args.exp}`;
78
switch (args.actionType) {
89
case 'phys':

server/arena/LogService/utils/format-message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function formatMessage(msgObj: SuccessArgs | FailArgs, depth = 0): string
1414
return `${indent}${formatLong(msgObj)}${formatAction(msgObj)}\n${indent}${formatExp(msgObj)}`;
1515
}
1616

17+
console.log(msgObj.affects.length);
1718
const affects = msgObj.affects.map((msgObj) => formatCause(msgObj));
1819

1920
return `${indent}${formatLong(msgObj)}${formatAction(msgObj)}\n${indent}${formatExp(msgObj)}\n${affects.join('\n')}`;

server/arena/actions/attack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class Attack extends PhysConstructor {
4646
}
4747

4848
const { initiator, game } = ctx.params;
49-
throw new CastError(
50-
this.getSuccessResult({ initiator: affect.initiator, target: initiator, game }),
51-
);
49+
this.createContext(affect.initiator, initiator, game);
50+
51+
throw new CastError(this.getSuccessResult(this.context));
5252
}
5353
}
5454

0 commit comments

Comments
 (0)