소스 검색

Allow stat tests to be biased

master
Fen Dweller 5 년 전
부모
커밋
7a959036bb
2개의 변경된 파일10개의 추가작업 그리고 8개의 파일을 삭제
  1. +1
    -1
      src/game/combat/actions.ts
  2. +9
    -7
      src/game/combat/tests.ts

+ 1
- 1
src/game/combat/actions.ts 파일 보기

@@ -33,7 +33,7 @@ export abstract class DamageAction extends Action {
desc,
[new CapableCondition(), new EnemyCondition()].concat(conditions)
)
this.test = new StatTest(Stat.Power)
this.test = new StatTest(Stat.Power, 10)
}

execute (user: Creature, target: Creature): LogEntry {


+ 9
- 7
src/game/combat/tests.ts 파일 보기

@@ -30,10 +30,11 @@ abstract class RandomTest implements CombatTest {

export class StatVigorTest extends RandomTest {
private f: (x: number) => number
private k = 0.1

constructor (public readonly stat: Stat, k = 0.1) {
constructor (public readonly stat: Stat, private bias = 0) {
super()
this.f = logistic(0, 1, k)
this.f = logistic(0, 1, this.k)
}

odds (user: Creature, target: Creature): number {
@@ -56,7 +57,7 @@ export class StatVigorTest extends RandomTest {
userPercent *= 4
}

return this.f(user.stats[this.stat] * userPercent - target.stats[this.stat] * targetPercent)
return this.f(this.bias + user.stats[this.stat] * userPercent - target.stats[this.stat] * targetPercent)
}

explain (user: Creature, target: Creature): LogEntry {
@@ -82,7 +83,7 @@ export class StatVigorTest extends RandomTest {
}
const userMod = user.stats[this.stat] * userPercent
const targetMod = target.stats[this.stat] * targetPercent
const delta = (userMod - targetMod)
const delta = userMod - targetMod

if (delta === 0) {
result = new LogLine('You and the target have the same effective', new PropElem(this.stat), '.')
@@ -100,14 +101,15 @@ export class StatVigorTest extends RandomTest {

export class StatTest extends RandomTest {
private f: (x: number) => number
private k = 0.1

constructor (public readonly stat: Stat, k = 0.1) {
constructor (public readonly stat: Stat, private bias = 0) {
super()
this.f = logistic(0, 1, k)
this.f = logistic(0, 1, this.k)
}

odds (user: Creature, target: Creature): number {
return this.f(user.stats[this.stat] - target.stats[this.stat])
return this.f(this.bias + user.stats[this.stat] - target.stats[this.stat])
}

explain (user: Creature, target: Creature): LogEntry {


불러오는 중...
취소
저장