// Constructor internal Game(Account account) { Server = new ServerGame(); Character = new CharacterGame(account); Map = new MapGame(account); Fight = new FightGame(account); Managers = new ManagersGame(account, Map); Chat = new ChatGame(account); Npcs = new NpcsGame(account); Storage = new StorageGame(account); Exchange = new ExchangeGame(account); Bid = new BidGame(account); }
private static bool CanBeTackled(FightGame fight, FighterEntry actor) { if (actor.Stats.InvisibilityState != 3) { return(false); } // TODO: Add carried condition if (fight.HasState(96) || fight.HasState(6)) { return(false); } return(true); }
/// <summary> /// /// </summary> void Start() { tmpstr = typeof(FightInrto).ToString(); FightInrto introp = new FightInrto(this, tmpstr); procMgr.Add(tmpstr, introp); tmpstr = typeof(FightReady).ToString(); FightReady readyp = new FightReady(this, tmpstr); procMgr.Add(tmpstr, readyp); tmpstr = typeof(FightGame).ToString(); FightGame gamep = new FightGame(this, tmpstr); procMgr.Add(tmpstr, gamep); tmpstr = typeof(FightPowerUp).ToString(); FightPowerUp powp = new FightPowerUp(this, tmpstr); procMgr.Add(tmpstr, powp); tmpstr = typeof(FightFinish).ToString(); FightFinish fishp = new FightFinish(this, tmpstr); procMgr.Add(tmpstr, fishp); tmpstr = typeof(FightResult).ToString(); FightResult resp = new FightResult(this, tmpstr); procMgr.Add(tmpstr, resp); tmpstr = typeof(FightWarning).ToString(); FightWarning wrnp = new FightWarning(this, tmpstr); procMgr.Add(tmpstr, wrnp); procMgr.SetCurrProc("FightInrto"); }
private static void GetTackleCost(FightGame fight, List <FighterEntry> tacklers, int mp, int ap, out int mpCost, out int apCost) { mp = Math.Max(0, mp); ap = Math.Max(0, ap); mpCost = 0; apCost = 0; if (!CanBeTackled(fight, fight.PlayedFighter) || tacklers.Count == 0) { return; } for (int i = 0; i < tacklers.Count; i++) { if (!tacklers[i].Alive) { continue; } if (!CanBeTackler(tacklers[i], fight.PlayedFighter)) { continue; } var tackleRatio = GetTackleRatio(fight.PlayedFighter, tacklers[i]); if (tackleRatio >= 1) { continue; } mpCost += (int)(mp * (1 - tackleRatio) + 0.5); apCost += (int)(ap * (1 - tackleRatio) + 0.5); } }
public static Dictionary <short, MoveNode> GetReachableZone(FightGame fight, Map map, short currentCellId) { Dictionary <short, MoveNode> zone = new Dictionary <short, MoveNode>(); if (fight.PlayedFighter.MovementPoints <= 0) { return(zone); } var maxDistance = fight.PlayedFighter.MovementPoints; List <PathNode> opened = new List <PathNode>(); Dictionary <short, PathNode> closed = new Dictionary <short, PathNode>(); var node = new PathNode(currentCellId, fight.PlayedFighter.MovementPoints, fight.PlayedFighter.ActionPoints, 0, 0, 1); opened.Add(node); closed[currentCellId] = node; while (opened.Count > 0) { var current = opened.Last(); opened.Remove(current); var cellId = current.CellId; var neighbours = MapPoint.GetNeighbourCells(cellId, false); var tacklers = new List <FighterEntry>(); int i = 0; while (i < neighbours.Count) { var tackler = fight.Fighters.FirstOrDefault(f => f.CellId == neighbours[i]?.CellId); if (neighbours[i] != null && tackler == null) { i++; continue; } neighbours.RemoveAt(i); if (tackler != null) { tacklers.Add(tackler); } } GetTackleCost(fight, tacklers, current.AvailableMp, current.AvailableAp, out int mpCost, out int apCost); var availableMp = current.AvailableMp - mpCost - 1; var availableAp = current.AvailableAp - apCost; var tackleMp = current.TackleMp + mpCost; var tackleAp = current.TackleAp + apCost; var distance = current.Distance + 1; var reachable = availableMp >= 0; // TODO: Handle marked cells for (i = 0; i < neighbours.Count; i++) { if (closed.ContainsKey(neighbours[i].CellId)) { var previous = closed[neighbours[i].CellId]; if (previous.AvailableMp > availableMp) { continue; } if (previous.AvailableMp == availableMp && previous.AvailableAp >= availableAp) { continue; } } if (!map.Cells[neighbours[i].CellId].IsWalkable(true)) { continue; } zone[neighbours[i].CellId] = new MoveNode(apCost, mpCost, cellId, reachable); node = new PathNode(neighbours[i].CellId, availableMp, availableAp, tackleMp, tackleAp, distance); closed[neighbours[i].CellId] = node; if (current.Distance < maxDistance) { opened.Add(node); } } } foreach (short cellKey in zone.Keys) { zone[cellKey].Path = GetPath(currentCellId, cellKey, zone); } return(zone); }