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
def finishInvasionBattle( | |
state: State, | |
invasion: FinishInvasionBattle, | |
userId: String | |
) : (State, List[TrackingMessage]) = { | |
validate(state, invasion.userId) | |
val (afterBattle, calls) = battleEffects(state, userId)(invasion) | |
(resetTarget(afterBattle)(invasion), calls) | |
} |
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
"POST", "/api/user/invasion/buy_new_target/#{uuid}", {}) | |
"POST", "/api/user/invasion/finish_invasion_battle/#{uuid}", { | |
"attacker" => // Attacker uuid, | |
"result" => // Either "win" "lose" "surrender", | |
"army" => // A string with the Battle info like in FinishPvE |
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
{ | |
"invasionTimeout": 86400, | |
"invasionExtensionTime": 3600, | |
"invasionArmyCap": 5, | |
"notificationThresshold": 10, | |
"targetResetPrice": { | |
"resource": "gold", | |
"amount": 1000 | |
}, | |
"maps": [ |
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
UserState: | |
{ | |
<new field> | |
itemDetails: [ | |
<Same as ItemConfig> | |
{ | |
"i18n": { | |
"description": "This is a generated item.", | |
"title": "" | |
}, |
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
def updateResourceProgress(state: State, timestamp: Long): State = { | |
val secondsSinceLastUpdate = (timestamp - state.metaData.lastUpdate) | |
logger.debug(s"secondsSinceLastLogin $secondsSinceLastUpdate") | |
val updatedResources: Map[String, Resource] = state.resources.map { | |
case (resourceName, resource) => { | |
val modifier = resource.productionRate * resource.rateModifier / 1000 | |
val productionRate = resource.productionRate + modifier | |
val addedResources = (productionRate.toFloat / 3600.toFloat * secondsSinceLastUpdate).ceil.toLong | |
logger.debug(s"adding $addedResources to $resourceName for $secondsSinceLastUpdate s - ${productionRate}/h") |
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 Data.List | |
removeNegatives = filter $ not . (< 0) . head | |
removeEmpties = filter $ not . null | |
safeTail (x:xs) = xs | |
safeTail x = x | |
parts [] = [] |
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
public static TResult Aggregate<TSource, TAccumulate, TResult> (this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector) { | |
return System.Linq.Aggregate(source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector) ; | |
} | |
public static TAccumulate Aggregate<TSource, TAccumulate> (this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func) { | |
return System.Linq.Aggregate (source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func); | |
} | |
public static bool All<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate) { |
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
-- Before caching RoF fitness | |
-- 00:00:00.1983681 | |
RoF Fitness: 00:00:00.0025516 | |
Fitness total: 00:00:00.0055062 | |
Actions: 00:00:00.0664216 | |
Playing total: 00:00:00.0255507 | |
-- After caching RoF fitness | |
-- 00:00:00.2025582 |
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
;; Gist | |
(require 'gist) |
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
sealed case class Sphere (center:Vector3d , radius: Double) | |
{ | |
val center = center; | |
def intersect (): Option [(Vector3d)]= { | |
return Some(this.center); | |
} | |
} |
OlderNewer