static int Solve2(string raw) { var input = Transform(raw); var lookup = new Dictionary <string, AxialCoord>(); lookup["n"] = AxialCoord.Right; lookup["ne"] = AxialCoord.DownRight; lookup["se"] = AxialCoord.DownLeft; lookup["s"] = AxialCoord.Left; lookup["sw"] = AxialCoord.UpLeft; lookup["nw"] = AxialCoord.UpRight; var pos = new AxialCoord(); int max = 0; foreach (var op in input) { pos += lookup[op]; var dist = AxialCoord.Distance(pos, new AxialCoord()); if (dist > max) { max = dist; } } return(max); }
public static bool IsAbilityUsableFrom(GameInstance game, CachedMob mob, AxialCoord from, CachedMob target, int abilityId) { var ability = game.MobManager.Abilities[abilityId]; int remainingAp = mob.MobInstance.Ap - game.Pathfinder.Distance(mob.MobInstance.Coord, from); bool withinRange = ability.Range >= from.Distance(target.MobInstance.Coord); bool enoughAp = remainingAp >= ability.Cost; bool notOnCooldown = game.State.Cooldowns[abilityId] == 0; return(withinRange && enoughAp && notOnCooldown); }
static int Solve(string raw) { var input = Transform(raw); var lookup = new Dictionary <string, AxialCoord>(); lookup["n"] = AxialCoord.Right; lookup["ne"] = AxialCoord.DownRight; lookup["se"] = AxialCoord.DownLeft; lookup["s"] = AxialCoord.Left; lookup["sw"] = AxialCoord.UpLeft; lookup["nw"] = AxialCoord.UpRight; var pos = new AxialCoord(); foreach (var op in input) { pos += lookup[op]; } var result = AxialCoord.Distance(pos, new AxialCoord()); return(result); }