Added a configuration file for seting up parameters

This commit is contained in:
dalyjame
2019-06-16 14:17:52 -04:00
parent b6fc98f44e
commit a475126a3f
15 changed files with 63 additions and 20 deletions

View File

@@ -53,10 +53,10 @@ object Ability {
private val header = """
|import scala.util.Random
|import fmon.battle.msg._
|import fmon._
|import fmon.stat._
|import fmon.stat.MoveType._
|import fmon.stat.Statistic._
|import fmon.util._
"""
private val helper = """
implicit val gen = rng

View File

@@ -2,6 +2,7 @@ package fmon.stat
import scala.util._
import fmon._
import fmon.battle.msg._
import fmon.util._
@@ -69,7 +70,7 @@ class Monster(val base : StorageMon) {
def applyBoost(s : Stat, boost : Int, effect: EffectSource)(implicit reader: SignalConsumer, rng: Random) {
val modified = boosts.getOrElse(s, 0) + boost
boosts = boosts.updated(s, Math.min(MaxBoost, Math.max(-MaxBoost, modified)))
boosts = boosts.updated(s, Math.min(Config.maxBoost, Math.max(-Config.maxBoost, modified)))
if (boost > 0) {
reader ! Message(s"$this's $s rose!")
} else if (boost < 0) {
@@ -93,8 +94,6 @@ class Monster(val base : StorageMon) {
}
object Monster {
final val MaxBoost = 6
def generate(nickname: String, ot: TrainerID, xp: Int, form: Form, moves: IndexedSeq[Move])(implicit rng: Random) = {
new Monster(StorageMon.generate(nickname, ot, xp, form, moves))
}

View File

@@ -9,6 +9,7 @@ import scala.io.Source
import scala.util.Random
import Statistic._
import fmon._
import fmon.battle.msg.{Message, SignalConsumer}
import fmon.util._
@@ -142,7 +143,7 @@ abstract class Move extends MoveTurn {
val actualPow = if (powCallback != null) powCallback(user, this, target, reader, rng) else pow
val baseDmg = (2 * user.level / 5 + 2) * actualPow * user(atkStat) / (target(defStat) * 50) + 2
val effectiveness = target.effectiveness(element)
val multiplier = effectiveness * critMultiplier(user, target)
val multiplier = effectiveness * critMultiplier(user, target) * stabMultiplier(user)
if (effectiveness > 1.0) {
reader ! Message("It's super effective!")
} else if (effectiveness < 1.0) {
@@ -160,7 +161,15 @@ abstract class Move extends MoveTurn {
val chance = (1 << stage) \\ 16 // Doubles per stage
if (rng.chance(chance)) {
reader ! Message("A critical hit!")
1.5
Config.crit
} else {
1.0
}
}
def stabMultiplier(user: Monster) = {
if (user.elements.contains(element)) {
Config.stab
} else {
1.0
}
@@ -259,6 +268,7 @@ object Move {
val tree = tb.parse(
s"""
|import scala.util.Random
|import fmon._
|import fmon.battle.msg._
|import fmon.stat._
|import fmon.stat.Statistic._

View File

@@ -2,6 +2,8 @@ package fmon.stat
import scala.util.Random
import fmon._
import Statistic._
object Nature extends Enumeration {

View File

@@ -2,6 +2,7 @@ package fmon.stat
import scala.util.Random
import fmon._
import fmon.battle.Action
import fmon.stat.Target._

View File

@@ -7,6 +7,7 @@ import scala.util.Random
import scala.io.Source
import fmon._
import fmon.battle.msg._
import fmon.util._
import EffectType.Volatile
@@ -124,10 +125,11 @@ object Status {
private val header = """
import scala.util.Random
import fmon.battle.msg._
import fmon._
import fmon.stat._
import fmon.stat.MoveType._
import fmon.stat.Statistic._
import fmon.util._
import fmon.util.Fraction
"""
private val helpers = """
def msg(text: String): Unit = {

View File

@@ -2,7 +2,7 @@ package fmon.stat
import scala.util.Random
import fmon.util._
import fmon._
class StorageMon(val nickname : String, val xp: Int, val gene : Gene, val form : Form, val evs : Map[Stat, Int], val moves : IndexedSeq[Move], val ability: Ability) {
def level = form.xpCurve(xp)

View File

@@ -15,8 +15,6 @@ package object stat {
type Target = Target.Value
type XpCurve = XpCurve.Val
implicit def rngDice(rng : Random) = new Dice(rng)
implicit def ptrToMonster(ptr : MonsterPtr) : Monster = ptr.mon
implicit def templateToStatus(status: StatusTemplate): Status = status.build
}