Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created May 2, 2011 14:39
Show Gist options
  • Save kiy0taka/951698 to your computer and use it in GitHub Desktop.
Save kiy0taka/951698 to your computer and use it in GitHub Desktop.
@Grab('net.sf.groovydice:groovydice:1.4.1')
import net.sf.groovydice.*
class TinTiroRinPlugin {
def dynamicMethods = { api ->
api.add(method:'ttr') { dice ->
if (dice.allDice.size() != 3) return "ションベン!"
def stats = [all:dice.allDice, count:dice.allDice.countBy{it}]
switch (stats) {
case { it.count.size() == 1 && it.count[1] }:
return "$stats.all ピンゾロ(5倍づけ)です。"
case { it.count.size() == 1 }:
return "$stats.all ${stats.count.findResult{it.key}}のゾロ目(3倍づけ)です。"
case { it.count.size() == 2 }:
return "$stats.all ${stats.count.find{it.value == 1}.key}です。"
case { it.all.sum() == 6 }:
return "$stats.all ヒフミ(2倍払い)です。"
case { it.all.sum() == 15 }:
return "$stats.all シゴロ(2倍づけ)です。"
default:
return "$stats.all 目無しです。"
}
}
}
}
def config = new GroovyDice()
config.pluginManager.register(new TinTiroRinPlugin())
config.initialize()
println 3.d.ttr()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment