public int GetShips(int strength) { if (Ships.ContainsKey(strength)) { return(Ships[strength]); } else { return(0); } }
/// <summary> /// Places a new ship on the board, or changes an existing ship. /// </summary> /// <param name="type">The type of ship to place (unique identifier).</param> /// <param name="data">Metadata pertaining to this ship.</param> public void PlaceShip(ShipType type, Ship data) { if (Ships.ContainsKey(type)) { Ships[type] = data; } else { Ships.Add(type, data); } }
public void AddShips(int strength, int count) { if (Ships.ContainsKey(strength)) { Ships[strength] += count; } else { Ships.Add(strength, count); } }
public void Store(string ShipFD, int id, string station, string system) { string sid = Key(ShipFD, id); if (Ships.ContainsKey(sid)) // if we don't have it, don't worry { //System.Diagnostics.Debug.WriteLine(ShipFD + " store on buy at " + system); Ships[sid] = Ships[sid].Store(station, system); } else { System.Diagnostics.Debug.WriteLine(ShipFD + " cannot find ship to store on buy"); } }
public void Sell(string ShipFD, int id) { string sid = Key(ShipFD, id); if (Ships.ContainsKey(sid)) // if we don't have it, don't worry { //System.Diagnostics.Debug.WriteLine(ShipFD + " Sell "); Ships[sid] = Ships[sid].SellShip(); } else { System.Diagnostics.Debug.WriteLine(ShipFD + " can't find to Sell"); } }
public void AddShips(Dictionary <int, int> new_ships) { foreach (var i in new_ships) { if (Ships.ContainsKey(i.Key)) { Ships[i.Key] += i.Value; } else { Ships.Add(i.Key, i.Value); } } }
public void Merge(Fleet other) { foreach (var i in other.Ships) { if (Ships.ContainsKey(i.Key)) { Ships[i.Key] += i.Value; } else { Ships.Add(i.Key, i.Value); } } other.RemoveAll(); }
private ShipInformation EnsureShip(int id) // ensure we have an ID of this type.. { if (Ships.ContainsKey(id)) { ShipInformation sm = Ships[id]; if (!sm.Sold) // if not sold, ok { return(sm); } else { Ships[newsoldid++] = sm; // okay, we place this information on 30000+ all Ids of this will now refer to new entry } } ShipInformation smn = new ShipInformation(id); Ships[id] = smn; return(smn); }
public int RemoveShips(int strength, int count) { if (Ships.ContainsKey(strength)) { if (Ships[strength] < count) { count = Ships[strength]; Ships.Remove(strength); } else { Ships[strength] -= count; } return(count); } else { return(0); } }
private ShipInformation EnsureShip(string id) // ensure we have an ID of this type.. { if (Ships.ContainsKey(id)) { ShipInformation sm = Ships[id]; if (!sm.Sold) // if not sold, ok { return(sm); } else { Ships[Key(sm.ShipFD, newsoldid++)] = sm; // okay, we place this information on 30000+ all Ids of this will now refer to new entry } } int i; id.Substring(id.IndexOf(":") + 1).InvariantParse(out i); ShipInformation smn = new ShipInformation(i); Ships[id] = smn; return(smn); }
private ShipInformation EnsureShip(string id) // ensure we have an ID of this type.. { if (Ships.ContainsKey(id)) { ShipInformation sm = Ships[id]; if (sm.State == ShipInformation.ShipState.Owned) // if owned, ok { return(sm); } else { Ships[Key(sm.ShipFD, newsoldid++)] = sm; // okay, we place this information on back ID list+ all Ids of this will now refer to new entry } } //System.Diagnostics.Debug.WriteLine("Made new ship " + id); ulong i = id.Substring(id.IndexOf(":") + 1).InvariantParseULong(0); ShipInformation smn = new ShipInformation(i); Ships[id] = smn; return(smn); }