public void Execute(CommodityVO reward) { ServantModel model = AmbitionApp.GetModel <ServantModel>(); switch (reward.Value) { case -1: AmbitionApp.SendMessage(ServantMessages.FIRE_SERVANT, reward.ID); model.Servants.RemoveAll(s => s.ID == reward.ID); model.Broadcast(); break; case 0: ServantVO servant = model.GetServant(reward.ID); if (servant?.IsHired ?? false) { AmbitionApp.SendMessage(ServantMessages.FIRE_SERVANT, reward.ID); } else { AmbitionApp.SendMessage(ServantMessages.INTRODUCE_SERVANT, reward.ID); } break; default: AmbitionApp.SendMessage(ServantMessages.HIRE_SERVANT, reward.ID); break; } }
public bool Introduce(ServantVO servant) { if (RemoveFromDictionary(Unknown, servant) && AddToDictionary(Applicants, servant)) { servant.Status = ServantStatus.Introduced; AmbitionApp.SendMessage(ServantMessages.SERVANT_INTRODUCED, servant); return(true); } return(false); }
public void Execute(string servantID) { ServantModel model = AmbitionApp.GetModel <ServantModel>(); ServantVO servant = model.GetServant(servantID); if (servant != null && servant.Status == ServantStatus.Hired) { servant.Status = ServantStatus.Introduced; model.Broadcast(); } }
public void Execute(ServantType type) { ServantModel model = AmbitionApp.GetModel <ServantModel>(); ServantVO servant = model.GetServant(type); if (servant != null) { servant.Status = ServantStatus.Introduced; model.Broadcast(); } }
public bool Hire(ServantVO servant) { if (!Servants.ContainsKey(servant.Slot) && RemoveFromDictionary(Applicants, servant)) { servant.Status = ServantStatus.Hired; Servants[servant.Slot] = servant; AmbitionApp.SendMessage <ServantVO>(ServantMessages.SERVANT_HIRED, servant); return(true); } return(false); }
public void Execute(string servantID) { ServantModel model = AmbitionApp.GetModel <ServantModel>(); ServantVO servant = model.LoadServant(servantID); if (servant != null && !servant.IsHired) { if (model.GetServant(servant.Type)?.ID != servant.ID) { AmbitionApp.SendMessage(ServantMessages.FIRE_SERVANT, servant.Type); } servant.Status = ServantStatus.Hired; model.Broadcast(); } }
public ServantVO LoadServant(string servantID) { ServantVO servant = GetServant(servantID); if (servant != null) { return(servant); } servant = Resources.Load <ServantConfig>(SERVANT_PATH + servantID)?.GetServant(); if (servant != null) { Servants.Add(servant); Broadcast(); } return(servant); }
public void Execute(CommodityVO reward) { ServantModel servants = AmbitionApp.GetModel <ServantModel>(); ServantVO servant = null; if (!servants.Servants.ContainsKey(reward.ID) && servants.Applicants.ContainsKey(reward.ID)) { servant = Util.RNG.TakeRandom(servants.Applicants[reward.ID].ToArray()); servants.Hire(servant); } if (servant == null) { reward.Type = CommodityType.Gossip; AmbitionApp.Reward(reward); } }
public ServantVO GetServant() { ServantVO result = new ServantVO() { ID = name, Type = Type, Wage = Wage, Status = Status, Modifiers = new Dictionary <string, float>() }; foreach (SerializableHash <string, float> mod in Modifiers) { result.Modifiers[mod.Key] = mod.Value; } return(result); }
public bool Introduce(string servantType) { List <ServantVO> servants; if (!Unknown.TryGetValue(servantType, out servants) || servants.Count == 0) { return(false); } ServantVO servant = Util.RNG.TakeRandom(servants.ToArray()); if (AddToDictionary(Applicants, servant)) { Unknown[servantType].Remove(servant); servant.Status = ServantStatus.Introduced; AmbitionApp.SendMessage(ServantMessages.SERVANT_INTRODUCED, servant); return(true); } return(false); }
public string GetServantDescription(ServantVO servant) { return(AmbitionApp.Localize(ServantConsts.SERVANT_DESCRIPTION_KEY + servant.ID)); }
public string GetServantTitle(ServantVO servant) { return(AmbitionApp.Localize(ServantConsts.SERVANT_TITLE_KEY + servant.ID)); }
public string GetServantName(ServantVO servant) { return(AmbitionApp.Localize(ServantConsts.SERVANT_LOC_KEY + servant.ID)); }
private bool RemoveFromDictionary(Dictionary <string, List <ServantVO> > dictionary, ServantVO servant) { string slot = servant.Slot; bool result = dictionary.ContainsKey(slot) && dictionary[slot].Remove(servant); if (dictionary[slot].Count == 0) { dictionary.Remove(slot); } return(result); }
private bool AddToDictionary(Dictionary <string, List <ServantVO> > dictionary, ServantVO servant) { if (!dictionary.ContainsKey(servant.Slot)) { dictionary[servant.Slot] = new List <ServantVO>(); } else if (dictionary[servant.Slot].Contains(servant)) { return(false); } dictionary[servant.Slot].Add(servant); return(true); }
public bool Fire(ServantVO servant) { return((Servants.ContainsKey(servant.Slot) && Servants[servant.Slot] == servant) && Fire(servant.Slot)); }