private static async Task ActionOrphanage(CharacterEntity e) { // TODO:[TALENT] float x = (float)Global.rng.NextDouble(); if (x < 0.3f) { P.ui.SetTitle("Visit at the Orphanage"); P.ui.NoHead(); P.ui.SetDescription(string.Format( ORPHAN_FAILED.Random(), e.MetaName() )); P.ui.SetButtons("Continue"); await P.ui.ButtonPressed(); return; } CharacterEntity potentialChild = CharacterEntity.Orphan(); int gold = 5 * Global.rng.Next(2, 7); P.ui.SetTitle("Visit at the Orphanage"); P.ui.SetAdoption(e, potentialChild); P.ui.SetDescription(string.Format( "{0} found a cute child called {1}. The owners of the orphanage ask for a donation of {2}.", e.MetaName(), potentialChild.name, gold )); bool enoughMoney = Game.data.inventory.gold >= gold; P.ui.SetButtons(string.Format("Adopt (Pay {0})", gold), "Decline", "Bargain"); if (!enoughMoney) { P.ui.buttonValidate.Text = "Not enough gold"; P.ui.buttonValidate.Disabled = true; } UI.Outcome.ButtonOutcome pressed = await P.ui.ButtonPressed(); if (pressed == UI.Outcome.ButtonOutcome.THIRD) { int nD = 5 * Global.rng.Next(1, 8); if (nD < gold) { gold = nD; P.ui.AddDescription( string.Format("\n You convince the orphanage that {0} is enough.", gold) ); P.ui.SetButtons(string.Format("Adopt (Pay {0})", gold), "Decline"); enoughMoney = Game.data.inventory.gold >= gold; if (!enoughMoney) { P.ui.buttonValidate.Text = "Not enough gold"; P.ui.buttonValidate.Disabled = true; } } else { P.ui.AddDescription( "\n The orphanage is offended that you are trying to bargain." ); P.ui.buttonValidate.Disabled = false; P.ui.SetButtons("Continue"); await P.ui.ButtonPressed(); return; } pressed = await P.ui.ButtonPressed(); } P.ui.buttonValidate.Disabled = false; if (potentialChild != null && pressed.Yes()) { AddOrphan(e, potentialChild); } }
public static bool Yes(this UI.Outcome.ButtonOutcome button) { return(button == UI.Outcome.ButtonOutcome.VALIDATE); }