public void playerUnderAttack(List <int> intArguments) { bool youBlocked; List <CardGUIModel> defenders = null; GUIWindows.GUISelect gUISelect = null; /* * intArguments[0] - the attacker */ engageBattleOPP(intArguments[0]); youBlocked = false; if (canBlock(intArguments[0])) { string message; defenders = getOwnDefendersThatCanBlock(); message = "Select one defender to block the attack with, or don't block at all."; gUISelect = new GUIWindows.GUISelect(defenders, message, 1, null); gUISelect.replaceCancelButtonMessage("Don't defend"); gUISelect.ShowDialog(); // you blocked the attack if (!gUISelect.wasCanceled) { youBlocked = true; } } if (youBlocked) { int index; index = listOwnBattleGround.IndexOf(defenders[gUISelect.selected[0]]); engageBattleOWN(index); // you add the target of the attacker to the index of the defender intArguments.Add(index); sendBattle(intArguments); Battle(intArguments, false); } else { // you lost ctrl.send(new GameMessage( "ISURRENDER", ctrl.GameRoomID )); loadEndGame(false); } }
// creature is under attack public void creatureUnderAttack(List <int> intArguments) { bool youBlocked; List <CardGUIModel> defenders = null; GUIWindows.GUISelect gUISelect = null; /* * intArguments[0] - the attacker * intArguments[1] - the creature that is being attacked */ engageBattleOPP(intArguments[0]); youBlocked = false; if (canBlock(intArguments[0])) { string message; defenders = getOwnDefendersThatCanBlock(); if (defenders.Count != 0) { message = "Select one defender to block the attack with, or don't block at all."; gUISelect = new GUIWindows.GUISelect(defenders, message, 1, null); gUISelect.replaceCancelButtonMessage("Don't defend"); gUISelect.ShowDialog(); // you blocked the attack if (!gUISelect.wasCanceled) { youBlocked = true; } } } if (youBlocked) { int index; index = listOwnBattleGround.IndexOf(defenders[gUISelect.selected[0]]); engageBattleOWN(index); // you modify the target of the attacker to the index of the defender intArguments[1] = index; //notify the server that 2 creatures will battle sendBattle(intArguments); Battle(intArguments, false); } else { sendBattle(intArguments); Battle(intArguments, false); } }
// safeguards are being attacked public void safeguardsUnderAttack(List <int> intArguments) { bool youBlocked; List <CardGUIModel> defenders = null; GUIWindows.GUISelect gUISelect = null; /* * intArguments[0] - the attacker * intArguments[1..] - the safeguards that are being attacked */ engageBattleOPP(intArguments[0]); youBlocked = false; if (canBlock(intArguments[0])) { string message; defenders = getOwnDefendersThatCanBlock(); message = "Select one defender to block the attack with, or don't block at all."; gUISelect = new GUIWindows.GUISelect(defenders, message, 1, null); gUISelect.replaceCancelButtonMessage("Don't defend"); gUISelect.ShowDialog(); // you blocked the attack if (!gUISelect.wasCanceled) { youBlocked = true; } } if (youBlocked) { int index; index = listOwnBattleGround.IndexOf(defenders[gUISelect.selected[0]]); engageBattleOWN(index); // you modify the target of the attacker to the index of the defender intArguments[1] = index; sendBattle(intArguments); Battle(intArguments, false); } else { // you delete the attacker from the list of arguments intArguments.RemoveAt(0); sendBrokenSafeguards(intArguments); } }