public RewardRange(ref CommodityVO arg) { Type = arg.Type; ID = arg.ID; Low = arg.Value; High = arg.Value; }
public void Execute(RendezVO rendez) { if (rendez.RSVP != RSVP.Required) { AmbitionApp.GetModel <CharacterModel>().Characters.TryGetValue(rendez.Character, out CharacterVO character); rendez.RSVP = RSVP.Declined; if (character != null) { if (character.LiaisonDay == rendez.Day) { character.LiaisonDay = -1; } if (character.Rejections < 4) { ++character.Rejections; } CommodityVO penalty = new CommodityVO() { Type = CommodityType.Favor, ID = rendez.Character, Value = -character.Rejections }; AmbitionApp.SendMessage(penalty); AmbitionApp.GetModel <CharacterModel>().Broadcast(); } AmbitionApp.SendMessage(rendez); } }
public void Execute(PartyVO party) { CalendarModel calendar = AmbitionApp.Calendar; if (party == null || party.Day < calendar.Day) { return; } PartyModel model = AmbitionApp.GetModel <PartyModel>(); List <PartyVO> parties = new List <PartyVO>(calendar.GetOccasions <PartyVO>(party.Day)); RendezVO[] rendezs = calendar.GetOccasions <RendezVO>(party.Day); parties.Remove(party); if (party.RSVP == RSVP.Required || (!parties.Exists(p => p.IsAttending) && !Array.Exists(rendezs, r => r.IsAttending))) { parties.ForEach(p => AmbitionApp.SendMessage(PartyMessages.DECLINE_INVITATION, p)); Array.ForEach(rendezs, p => AmbitionApp.SendMessage(PartyMessages.DECLINE_INVITATION, p)); if (party.RSVP != RSVP.Required) { party.RSVP = RSVP.Accepted; } if (party.RSVP != RSVP.Required && party.Created == calendar.Day) { CommodityVO reward = new CommodityVO(CommodityType.Credibility, model.AcceptInvitationBonus); AmbitionApp.SendMessage(reward); } AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, party); // Dispatches Broadcast() } else { AmbitionApp.SendMessage(PartyMessages.DECLINE_INVITATION, party); } }
//To Do: Clean this up when CommodityVO uses RewardVO instead private string _commodityName(CommodityVO commodity) { string name; if (commodity.Type.ToString() == "Reputation") //Reputation is an edge case in terms of naming conventions { if (commodity.ID == "null") { name = localizationModel.GetString("commodity." + commodity.Type.ToString().ToLower() + ".name"); } else { name = localizationModel.GetString("commodity.reputation" + commodity.ID.ToLower() + ".name"); } } else if (commodity.Type.ToString() == "Gossip") //The commodity VO doesn't let us identify the tier and the faction of the Gossip until its already been issued { name = localizationModel.GetString("commodity." + commodity.Type.ToString().ToLower() + ".name"); } else { name = localizationModel.GetString("commodity." + commodity.ID + ".name"); } return(name); }
public RoomVO(RoomVO room) { Name = room.Name; Background = room.Background; Incident = room.Incident ?? _incident?.GetIncident(); Guests = room.Guests == null ? null : new CharacterVO[room.NumGuests]; for (int i = NumGuests - 1; i >= 0; i--) { Guests[i] = new CharacterVO(room.Guests[i]); } if (room.Actions != null) { Actions = new CommodityVO[room.Actions.Length]; for (int i = Actions.Length - 1; i >= 0; i--) { Actions[i] = new CommodityVO(room.Actions[i]); } } if (room.Rewards != null) { Rewards = new CommodityVO[room.Rewards.Length]; for (int i = Rewards.Length - 1; i >= 0; i--) { Rewards[i] = new CommodityVO(room.Rewards[i]); } } }
private void HandleReward(CommodityVO reward) { _queue.Add(reward); if (_queue.Count == 1) { StartCoroutine(StartRewards()); } }
public void AddCommidity(CommodityVO commodity) { if (commodity.Type != CommodityType.Incident && commodity.Type != CommodityType.Message) //Incidents and Messages don't get listed in the rewards because they aren't supposed to be treated like items { GameObject row = Instantiate(RowPrefab, ContentList.transform); CommodityRowView view = row.GetComponent <CommodityRowView>(); view.SetCommodity(commodity, CommodityConfig.GetSprite(commodity.Type.ToString())); } }
//To Do: Clean this up when CommodityVO uses RewardVO instead private string _commodityName(CommodityVO commodity) { switch (commodity.Type.ToString()) { case "Gossip": return(AmbitionApp.Localize("commodity." + commodity.Type.ToString().ToLower() + ".name")); } return(AmbitionApp.Localize("commodity." + commodity.ID + ".name")); }
private void HandleReward(CommodityVO reward) { if ((reward.Type == Reward) && ((OnGain && reward.Value > 0) || (OnLoss && reward.Value < 0) || (!OnLoss && !OnGain))) { AmbitionApp.Unsubscribe <CommodityVO>(HandleReward); AmbitionApp.Unsubscribe <CommodityVO[]>(HandleRewards); AmbitionApp.Subscribe <float>(GameMessages.FADE_OUT, HandleFade); StartCoroutine(ShowTooltip(DisplayDuration)); } }
public void Execute(GossipVO gossip) { if (gossip != null) { int value = AmbitionApp.Gossip.GetValue(gossip, AmbitionApp.Calendar.Day); CommodityVO profit = new CommodityVO(CommodityType.Livre, value); AmbitionApp.SendMessage(profit); AmbitionApp.Gossip.Gossip.Remove(gossip); ++AmbitionApp.Gossip.GossipActivity; AmbitionApp.Gossip.Broadcast(); } }
public void Execute() { PartyVO party = AmbitionApp.GetModel <PartyModel>().Party; OutfitVO outfit = AmbitionApp.Inventory.GetEquippedItem(ItemType.Outfit) as OutfitVO; AmbitionApp.GetModel <FactionModel>().Factions.TryGetValue(party.Faction, out FactionVO faction); int score = 200 - Math.Abs(faction.Modesty - outfit.Modesty) - Math.Abs(faction.Luxury - outfit.Luxury); int cred = (int)(score * outfit.Novelty * .001f); CommodityVO reward = new CommodityVO(CommodityType.Credibility, cred); AmbitionApp.SendMessage(reward); }
public void DecreaseFactionStat() { AmbitionApp.Politics.Factions.TryGetValue(_gossip.Faction, out FactionVO faction); if (faction != null) { CommodityVO reward = new CommodityVO( _gossip.IsPower ? CommodityType.Power : CommodityType.Allegiance, _gossip.Faction.ToString(), -_shift); AmbitionApp.SendMessage(reward); AmbitionApp.SendMessage(InventoryMessages.PEDDLE_INFLUENCE, _gossip); } }
public void Reward(CommodityVO commodity) { if (_rewardHandlers.TryGetValue(commodity.Type, out Action <CommodityVO> del)) { del(commodity); } #if DEBUG else { UnityEngine.Debug.LogError(">> Reward Factory error: \"" + commodity.Type + "\" is not a known reward type"); } #endif }
public override void OnEnter() { CalendarModel cal = AmbitionApp.Calendar; PartyVO[] parties = cal.GetOccasions <PartyVO>(cal.Day - 1); PartyVO party = Array.Find(parties, p => p.RSVP == RSVP.New); if (party != null) { CommodityVO penalty = new CommodityVO(CommodityType.Credibility, AmbitionApp.GetModel <PartyModel>().IgnoreInvitationPenalty); Dictionary <string, string> subs = new Dictionary <string, string>(); LocalizationModel loc = AmbitionApp.GetModel <LocalizationModel>(); party.RSVP = RSVP.Declined; subs["$PARTYNAME"] = loc.GetPartyName(party); subs["$CREDIBILITY"] = penalty.Value.ToString(); AmbitionApp.OpenDialog(DialogConsts.MISSED_RSVP_DIALOG, subs); AmbitionApp.SendMessage(penalty); } else { RendezVO[] dates = cal.GetOccasions <RendezVO>(cal.Day - 1); RendezVO date = Array.Find(dates, d => d.RSVP == RSVP.New); if (date != null) { CharacterModel characters = AmbitionApp.GetModel <CharacterModel>(); CharacterVO character = characters.GetCharacter(date.Character); bool isPenalized = !date.IsCaller; date.RSVP = RSVP.Declined; if (character != null) { character.LiaisonDay = -1; } AmbitionApp.SendMessage(date); if (isPenalized) { int penalty = characters.MissedRendezvousPenalty; CommodityVO favorPenalty = new CommodityVO() { Type = CommodityType.Favor, ID = date.Character, Value = penalty }; AmbitionApp.SendMessage(favorPenalty); Dictionary <string, string> subs = new Dictionary <string, string>(); subs["$SHORTNAME"] = AmbitionApp.GetModel <LocalizationModel>().GetShortName(character, date.Character); subs["$FAVOR"] = penalty.ToString(); AmbitionApp.OpenDialog(DialogConsts.MISSED_RENDEZVOUS_DIALOG, subs); } } } }
public void Execute(ItemVO item) { InventoryModel inventory = AmbitionApp.Inventory; int livre = AmbitionApp.Game.Livre; if (item != null && livre + item.Price >= 0 && inventory.Inventory.Remove(item)) { CommodityVO profit = new CommodityVO(CommodityType.Livre, item.Price); AmbitionApp.SendMessage(profit); // Seller will markup the used price. item.Price = (int)(item.Price / inventory.SellbackMultiplier); inventory.Market?.Add(item); inventory.Broadcast(); } }
// Adds new ranges or expands existing ones private List <RewardRange> Accumulate(List <RewardRange> ranges, List <RewardRange> rewards) { List <RewardRange> result = new List <RewardRange>(ranges); List <string> gossip = new List <string>(); GossipModel model = AmbitionApp.GetModel <GossipModel>(); string gossipName; RewardRange range; CharacterVO character; CommodityVO commodity; foreach (RewardRange reward in rewards) { switch (reward.Type) { case CommodityType.Gossip: commodity = new CommodityVO(CommodityType.Gossip, reward.ID, reward.Low); gossipName = model.GetName(commodity); if (!gossip.Contains(gossipName)) { gossip.Add(gossipName); range = new RewardRange(ref commodity); result.Add(range); } break; case CommodityType.Favor: character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(reward.ID); if (character?.FavoredLocations?.Length + character?.OpposedLocations?.Length > 0) { UpdateOrAdd(ref result, reward.Type, reward.ID, reward.Low, reward.High); } break; case CommodityType.Livre: case CommodityType.Credibility: case CommodityType.Peril: case CommodityType.Servant: UpdateOrAdd(ref result, reward.Type, reward.ID, reward.Low, reward.High, true); break; } } return(result); }
public void Execute(ItemVO item) { InventoryModel inventory = AmbitionApp.Inventory; if (item != null && AmbitionApp.Game.Livre >= item.Price && inventory.Market != null && inventory.Market.Remove(item)) { CommodityVO cost = new CommodityVO(CommodityType.Livre, -item.Price); AmbitionApp.SendMessage(cost); if (item.Created == default) { item.Created = AmbitionApp.GetModel <CalendarModel>().Today; } item.Price = (int)(item.Price * inventory.SellbackMultiplier); inventory.Inventory.Add(item); inventory.Broadcast(); } }
public void Reward(CommodityVO commodity) { // Will throw an exception _rewardHandlers[commodity.Type].Invoke(commodity); }
public static void Reward(CommodityVO commodity) { App.Service <RewardFactorySvc>().Reward(commodity); }
public void SetCommodity(CommodityVO commodity, Sprite icon) { Icon.sprite = icon; CommodityTF.text = _commodityName(commodity); ValueTF.text = "+" + commodity.Value.ToString(); }
public CommodityVO(CommodityVO commodity) : this(commodity.Type, commodity.ID, commodity.Value) { }
public void Execute() { CommodityVO penalty = new CommodityVO(CommodityType.Credibility, AmbitionApp.Game.ExhaustionPenalty); AmbitionApp.SendMessage(penalty); }