public void Init(ITimedChestPM i_pm) { mPM = i_pm; RewardView.Init(i_pm.RewardPM); SetModel(mPM.ViewModel); }
private void SendOpenRequestToServer(ITimedChestData i_data, ITimedChestPM i_chestPM) { Dictionary <string, string> cloudParams = new Dictionary <string, string>() { { "Id", i_data.GetId() } }; mBackend.MakeCloudCall(BackendMethods.OPEN_TIMED_CHEST, cloudParams, (result) => { OnOpenResponseFromServer(JsonConvert.DeserializeObject <OpenTimedChestResponse>(result["data"]), i_chestPM, i_data); }); }
public void OnOpenResponseFromServer(IOpenTimedChestResponse i_response, ITimedChestPM i_chestPM, ITimedChestData i_data) { if (i_response.IsOpeningVerified()) { IDungeonReward reward = RewardSpawner.Create(i_response.GetReward()); reward.Award(); UpdateNextAvailableTime(i_data.GetId(), i_response.GetNextAvailableTime()); i_chestPM.ShowOpenReward(reward); i_chestPM.UpdateProperties(); } }
public void WhenChestOpenResponseIsReceived_ChestPM_RewardGetsSet_And_UpdatePropertiesCalled() { ITimedChestPM mockPM = Substitute.For <ITimedChestPM>(); IOpenTimedChestResponse mockResponse = Substitute.For <IOpenTimedChestResponse>(); mockResponse.IsOpeningVerified().Returns(true); systemUnderTest.OnOpenResponseFromServer(mockResponse, mockPM, Substitute.For <ITimedChestData>()); mockPM.Received().ShowOpenReward(Arg.Any <IDungeonReward>()); mockPM.Received().UpdateProperties(); }
public void OpenChest(ITimedChestData i_data, ITimedChestPM i_chestPM) { RemoveKeysFromInventory(i_data); SendOpenRequestToServer(i_data, i_chestPM); }