Created
November 1, 2015 05:56
-
-
Save mike-neck/1320fbb1a855d3207684 to your computer and use it in GitHub Desktop.
dq8の追憶の亡霊のダメージ計算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.transform.* | |
enum Tension { | |
None(1.0), | |
First(1.7), | |
Second(3.0), | |
Third(5.0), | |
Final(7.5) | |
double correction | |
Tension(double c) { | |
this.correction = c | |
} | |
} | |
@ToString(excludes = 'wep,tec', includeNames = true) | |
class State { | |
final double wep | |
final double tec | |
final Tension tension | |
final boolean bikilt | |
State(double w, double t, Tension tens, boolean b) { | |
this.wep = w | |
this.tec = t | |
this.tension = tens | |
this.bikilt = b | |
} | |
} | |
def state = {w, t, tn, b -> | |
new State(w, t, tn, b) | |
} | |
interface Emperor { | |
int equip() | |
int notEquip() | |
} | |
interface AttackCondition { | |
Emperor with(State state) | |
} | |
class Soldier { | |
final double ofs | |
final double dfs | |
final double res | |
Soldier(double o, double d, double r) { | |
this.ofs = o | |
this.dfs = d | |
this.res = r | |
} | |
AttackCondition attackTo(Soldier other) { | |
def self = this | |
[with: {s -> | |
def r = s.tension == Tension.None ? other.res : s.tension.correction | |
def b = s.bikilt ? 2 : 1 | |
def dmg = (self.ofs/2 - other.dfs/4) * s.wep * s.tec * r * b | |
[ | |
equip: {dmg * 2 as int}, | |
notEquip: {dmg as int} | |
] as Emperor | |
}] as AttackCondition | |
} | |
} | |
soldier = {o, d, r -> | |
new Soldier(o, d, r) | |
} | |
def jessica = soldier(999, 999, 1) | |
def ghost = soldier(430, 135, 0.4) | |
[ | |
state(1.6, 1.8, Tension.None, false), | |
state(1.6, 1.8, Tension.None, true), | |
state(1.6, 1.8, Tension.First, false), | |
state(1.6, 1.8, Tension.First, true) | |
].collect { | |
[condition: it, damage: jessica.attackTo(ghost).with(it).equip()] | |
}.each { | |
println it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment