| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using DevilLink2.Gameplay;
- using DevilLink2.Persistence;
- using DevilLink2.Presentation;
- using DevilLink2.UI;
- using UnityEngine;
- namespace DevilLink2.Editor
- {
- internal static class ShopPlayAcceptance
- {
- private static int step;
- private static double started;
- private static double remaining;
- private static GameSession session;
- public static void Reset() { step=0; session=null; }
- public static bool Tick(UIManager ui,BoardDemoBootstrap bootstrap,Action<bool,string> check)
- {
- if(step==0)
- {
- ui.StartScreen.StartButton.onClick.Invoke(); ui.Lobby.ShopButton.onClick.Invoke();
- check(ui.Shop.IsVisible && ui.CurrentPage==UIPage.Lobby,"Lobby dock opens cached Shop overlay");
- check(bootstrap.GetComponentsInChildren<Canvas>(true).Length==1,"Single original Canvas");
- check(ui.Shop.RecordsText=="NO COIN RECORDS YET","Real empty ledger");
- ui.Shop.RecordsButton.onClick.Invoke(); check(ui.Shop.CurrentTab==ShopTab.CoinRecords,"Records tab");
- ui.Shop.ItemsButton.onClick.Invoke(); check(ui.Shop.CurrentTab==ShopTab.Items,"Items tab");
- ui.Shop.BuyButtons[0].onClick.Invoke();
- check(ui.Shop.CoinsLabel.text=="COINS 7,876","Hint purchase charged existing price");
- check(ui.Shop.StockLabels[0].text=="OWNED 2","Hint inventory incremented");
- check(ui.Lobby.CoinsLabel.text=="7,876","Underlying Lobby balance refreshed");
- ui.Shop.CloseButton.onClick.Invoke(); ui.Lobby.CoinButton.onClick.Invoke();
- check(ui.Shop.IsVisible,"Top coin entry opens Shop"); ui.Shop.CloseButton.onClick.Invoke();
- ui.Lobby.Cards[0].Button.onClick.Invoke(); session=bootstrap.Session; ui.GameShopButton.onClick.Invoke();
- check(ui.Shop.IsVisible && bootstrap.Flow.State==GameFlowState.Running,"Game entry keeps flow running");
- remaining=bootstrap.Flow.Runtime.Timer.RemainingTime; started=Time.realtimeSinceStartupAsDouble; step++; return false;
- }
- if(step==1)
- {
- if(Time.realtimeSinceStartupAsDouble-started<.8)return false;
- check(bootstrap.Flow.Runtime.Timer.RemainingTime<remaining,"Actual game loop counts down with Shop open");
- var id=Guid.NewGuid();
- check(ui.Shop.TryPurchase(ItemType.Time,id)==PurchaseStatus.Success,"Time purchase through UI");
- check(ui.Shop.TryPurchase(ItemType.Time,id)==PurchaseStatus.DuplicateTransaction,"Replayed operation rejected");
- check(bootstrap.SavedPlayer.Economy.Coins==4876,"Only one Time charge");
- check(bootstrap.SavedPlayer.Economy.Inventory.GetCount(ItemType.Time)==1,"Time stock +1");
- ui.Shop.BuyButtons[1].onClick.Invoke();
- check(ui.Shop.FeedbackLabel.text.Contains("NOT ENOUGH"),"Insufficient funds feedback");
- check(bootstrap.SavedPlayer.Economy.Coins==4876,"Failed purchase preserves balance");
- ui.Shop.RecordsButton.onClick.Invoke();
- check(ui.Shop.RecordsText.IndexOf("Shop: Time")<ui.Shop.RecordsText.IndexOf("Shop: Hint"),"Newest transaction first");
- check(ui.Shop.SummaryLabel.text.Contains("5,000"),"Retained spending summary");
- check(!bootstrap.SavedPlayer.HasPendingSave,"Purchases saved successfully");
- using(var restored=new SavedPlayer(new LocalSaveService(new FileSaveStorage(UnityEditor.SessionState.GetString("DevilLink2.Task08A.Play.Directory","")))))
- { check(restored.Economy.Coins==4876 && restored.Economy.Inventory.GetCount(ItemType.Time)==1,"Disk reload restores full purchase snapshot"); }
- ui.Shop.CloseButton.onClick.Invoke();
- check(bootstrap.Session==session && ui.CurrentPage==UIPage.Gameplay && bootstrap.Flow.State==GameFlowState.Running,"Close returns to same running board");
- ui.OpenShop(); bootstrap.Flow.Runtime.Timer.Advance(1000);
- check(!ui.Shop.IsVisible && ui.Hud.Result.IsVisible,"Timeout closes Shop and exposes real Result");
- check(bootstrap.GetComponentsInChildren<ShopScreen>(true).Length==1,"No repeated Shop instances");
- bool missing=false; foreach(var component in bootstrap.GetComponentsInChildren<Component>(true))if(component==null)missing=true;
- check(!missing,"No missing scene component");
- return true;
- }
- return false;
- }
- }
- }
|