Post by DanielD on Nov 1, 2021 15:01:27 GMT
Hi
I am trying to get things to add and carry out sequence of events but am having issues with the reactions for a duel player mode where i just take down an event of everything and store it then pass it on to the other client as though it were the NPC taking its turn.
the addreaction method doesnt seem to work but continues to end the enemy's turn but the perform reaction seems to add the cards but not the requested cards from the deck
can you help me understand how to trigger the add reaction or how to properly debug this issue maybe ?
when using the perform in the enemy system below - it seems to do the end enemy turn THEN performs the action.
public void DuelPlayerTakeTurn()
{
var system = container.GetAspect<CardSystem>();
for (var t = 0; t < GameViewSystem.OpponentPlayerEvents.Count; t++)
{
Debug.Log("got duel player take turn opponent event id: " + GameViewSystem.OpponentPlayerEvents[t].DuelPlayerEventID);
switch(GameViewSystem.OpponentPlayerEvents[t].EventName)
{
case "PlayCardAction":
foreach (var card in GameViewSystem.OpponentPlayerEvents[t].cards)
{
var cardToPlay = system.playable.FirstOrDefault(c => c.id == card);
if (cardToPlay != null)
{
var paction = new PlayCardAction(cardToPlay);
container.Perform(paction);
}
}
break;
case "DrawCardsAction":
Debug.Log("casting draw card action");
var cardsToDraw = GameViewSystem.OpponentPlayerEvents[t].cards;
foreach(var x in cardsToDraw)
Debug.Log(x);
var player = container.GetMatch().CurrentPlayer;
var daction = new DrawCardsAction(player, cardsToDraw);
container.AddReaction(daction);
break;
}
}
Debug.Log("end enemy turn");
container.GetAspect<MatchSystem>().ChangeTurn();
}
I am trying to get things to add and carry out sequence of events but am having issues with the reactions for a duel player mode where i just take down an event of everything and store it then pass it on to the other client as though it were the NPC taking its turn.
the addreaction method doesnt seem to work but continues to end the enemy's turn but the perform reaction seems to add the cards but not the requested cards from the deck
can you help me understand how to trigger the add reaction or how to properly debug this issue maybe ?
when using the perform in the enemy system below - it seems to do the end enemy turn THEN performs the action.
public void DuelPlayerTakeTurn()
{
var system = container.GetAspect<CardSystem>();
for (var t = 0; t < GameViewSystem.OpponentPlayerEvents.Count; t++)
{
Debug.Log("got duel player take turn opponent event id: " + GameViewSystem.OpponentPlayerEvents[t].DuelPlayerEventID);
switch(GameViewSystem.OpponentPlayerEvents[t].EventName)
{
case "PlayCardAction":
foreach (var card in GameViewSystem.OpponentPlayerEvents[t].cards)
{
var cardToPlay = system.playable.FirstOrDefault(c => c.id == card);
if (cardToPlay != null)
{
var paction = new PlayCardAction(cardToPlay);
container.Perform(paction);
}
}
break;
case "DrawCardsAction":
Debug.Log("casting draw card action");
var cardsToDraw = GameViewSystem.OpponentPlayerEvents[t].cards;
foreach(var x in cardsToDraw)
Debug.Log(x);
var player = container.GetMatch().CurrentPlayer;
var daction = new DrawCardsAction(player, cardsToDraw);
container.AddReaction(daction);
break;
}
}
Debug.Log("end enemy turn");
container.GetAspect<MatchSystem>().ChangeTurn();
}