Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add battlearena exception handle #6641

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 51 additions & 43 deletions nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -958,54 +958,62 @@ public IObservable<ActionEvaluation<BattleArena>> BattleArena(
int ticket
)
{
var action = new BattleArena
try
{
myAvatarAddress = States.Instance.CurrentAvatarState.address,
enemyAvatarAddress = enemyAvatarAddress,
costumes = costumes,
equipments = equipments,
runeInfos = runeInfos,
championshipId = championshipId,
round = round,
ticket = ticket
};

var sentryTrace = Analyzer.Instance.Track("Unity/BattleArena",
new Dictionary<string, Value>()
var action = new BattleArena
{
["championshipId"] = championshipId,
["round"] = round,
["enemyAvatarAddress"] = enemyAvatarAddress.ToString(),
["AvatarAddress"] = States.Instance.CurrentAvatarState.address.ToString(),
["AgentAddress"] = States.Instance.AgentState.address.ToString()
}, true);

var evt = new AirbridgeEvent("BattleArena");
evt.SetValue(championshipId);
evt.AddCustomAttribute("round", round);
evt.AddCustomAttribute("enemy-avatar-address", enemyAvatarAddress.ToString());
evt.AddCustomAttribute("agent-address", States.Instance.CurrentAvatarState.address.ToString());
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);
myAvatarAddress = States.Instance.CurrentAvatarState.address,
enemyAvatarAddress = enemyAvatarAddress,
costumes = costumes,
equipments = equipments,
runeInfos = runeInfos,
championshipId = championshipId,
round = round,
ticket = ticket
};

var sentryTrace = Analyzer.Instance.Track("Unity/BattleArena",
new Dictionary<string, Value>()
{
["championshipId"] = championshipId,
["round"] = round,
["enemyAvatarAddress"] = enemyAvatarAddress.ToString(),
["AvatarAddress"] = States.Instance.CurrentAvatarState.address.ToString(),
["AgentAddress"] = States.Instance.AgentState.address.ToString()
}, true);

var evt = new AirbridgeEvent("BattleArena");
evt.SetValue(championshipId);
evt.AddCustomAttribute("round", round);
evt.AddCustomAttribute("enemy-avatar-address", enemyAvatarAddress.ToString());
evt.AddCustomAttribute("agent-address", States.Instance.CurrentAvatarState.address.ToString());
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);

action.PayCost(Game.Game.instance.Agent, States.Instance, TableSheets.Instance);
LocalLayerActions.Instance.Register(action.Id, action.PayCost, _agent.BlockIndex);
ProcessAction(action);
_lastBattleActionId = action.Id;
return _agent.ActionRenderer.EveryRender<BattleArena>()
.Timeout(ActionTimeout)
.Where(eval => eval.Action.Id.Equals(action.Id))
.First()
.ObserveOnMainThread()
.DoOnError(e =>
{
if (_lastBattleActionId == action.Id)
action.PayCost(Game.Game.instance.Agent, States.Instance, TableSheets.Instance);
LocalLayerActions.Instance.Register(action.Id, action.PayCost, _agent.BlockIndex);
ProcessAction(action);
_lastBattleActionId = action.Id;
return _agent.ActionRenderer.EveryRender<BattleArena>()
.Timeout(ActionTimeout)
.Where(eval => eval.Action.Id.Equals(action.Id))
.First()
.ObserveOnMainThread()
.DoOnError(e =>
{
_lastBattleActionId = null;
}
if (_lastBattleActionId == action.Id)
{
_lastBattleActionId = null;
}

Game.Game.BackToMainAsync(HandleException(action.Id, e)).Forget();
}).Finally(() => Analyzer.Instance.FinishTrace(sentryTrace));
Game.Game.BackToMainAsync(HandleException(action.Id, e)).Forget();
}).Finally(() => Analyzer.Instance.FinishTrace(sentryTrace));
}
catch (Exception e)
{
Game.Game.BackToMainAsync(e).Forget();
return null;
}
}

public IObservable<ActionEvaluation<PatchTableSheet>> PatchTableSheet(
Expand Down
35 changes: 21 additions & 14 deletions nekoyume/Assets/_Scripts/UI/Widget/ArenaBattlePreparation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,27 @@ private void SendBattleArenaAction(int ticket = TicketCountToUse)
_info.PortraitId,
_info.AvatarAddr);

var costumes = States.Instance.CurrentItemSlotStates[BattleType.Arena].Costumes;
var equipments = States.Instance.CurrentItemSlotStates[BattleType.Arena].Equipments;
var runeInfos = States.Instance.CurrentRuneSlotStates[BattleType.Arena]
.GetEquippedRuneSlotInfos();
ActionRenderHandler.Instance.Pending = true;
ActionManager.Instance.BattleArena(
_info.AvatarAddr,
costumes,
equipments,
runeInfos,
_roundData.ChampionshipId,
_roundData.Round,
ticket)
.Subscribe();
try
{
var costumes = States.Instance.CurrentItemSlotStates[BattleType.Arena].Costumes;
var equipments = States.Instance.CurrentItemSlotStates[BattleType.Arena].Equipments;
var runeInfos = States.Instance.CurrentRuneSlotStates[BattleType.Arena]
.GetEquippedRuneSlotInfos();
ActionRenderHandler.Instance.Pending = true;
ActionManager.Instance.BattleArena(
_info.AvatarAddr,
costumes,
equipments,
runeInfos,
_roundData.ChampionshipId,
_roundData.Round,
ticket)
.Subscribe();
}
catch(Exception e)
{
Game.Game.BackToMainAsync(e).Forget();
}
}

public void OnRenderBattleArena(ActionEvaluation<BattleArena> eval)
Expand Down
Loading