Implement both styles of battle

This commit is contained in:
henriquenakashima 2020-09-30 22:48:32 -04:00
parent 6bf1a8672f
commit 838c30af99
3 changed files with 46 additions and 15 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
@ -43,8 +44,8 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
return discardPile;
}
public void DrawHand() {
for (int i = 0; i < DEFAULT_HAND_DRAWN; i++) {
public void DrawCards(int number) {
for (int i = 0; i < number; i++) {
DrawCardInternal();
}
TriggerHandPileChanged();
@ -52,9 +53,7 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
}
public void DrawCard() {
DrawCardInternal();
TriggerHandPileChanged();
TriggerDrawPileChanged();
DrawCards(1);
}
private void DrawCardInternal() {
@ -88,10 +87,19 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
}
public void DiscardHand() {
this.discardPile.InsertRange(0, this.handPile);
this.handPile.Clear();
TriggerHandPileChanged();
TriggerDiscardPileChanged();
DiscardInExcessOf(0);
}
public void DiscardInExcessOf(int max) {
int numberToDiscard = this.handPile.Count - max;
if (numberToDiscard > 0) {
IEnumerable<BaseCardT> rangeToDiscard = this.handPile.GetRange(0, numberToDiscard);
this.discardPile.InsertRange(0, rangeToDiscard.Reverse());
this.handPile.RemoveRange(0, numberToDiscard);
TriggerHandPileChanged();
TriggerDiscardPileChanged();
}
}
public void PutCardOnTopOfDrawPile(BaseCardT card) {