from random import shuffle
Dark = 0
Aether = 1
class Card:
def __init__(self, element, cost, name):
self.element = element
self.cost = cost
self.name = name
class Deck:
def __init__(self, mark, *deck):
self.mark = mark
self.deck = deck
sov = Card(Dark, 1, 'sov')
sovup = Card(Dark, 2, 'sov')
siphon = Card(Dark, 1, 'siphon')
drain = Card(Dark, 3, 'siphon')
bolt = Card(Aether, 2, 'bolt')
dim = Card(Aether, 6, 'dim')
dragon = Card(Dark, 10, 'dragon')
fractal = Card(Aether, 10, 'fractal')
aepend = Card(Aether, 0, 'aepend')
aependup = Card(Aether, -1, 'aependup')
dapend = Card(Dark, 0, 'dapend')
dapendup = Card(Dark, -1, 'dapendup')
dapill = Card(Dark, 0, 'dark')
dapillup = Card(Dark, -1, 'dark')
vagger = Card(Dark, 2, 'vagger')
class Player:
def __init__(self, build):
self.build = build
self.begin()
def begin(self):
self.q = [0, 0]
self.hp = 100
self.hand = []
self.sovs = 0
self.vag = False
self.dragons = 0
self.dims = 0
self.ap = 0
self.uap = 0
self.dm = 0
self.dp = 0
self.udp = 0
self.apstate = False
self.uapstate = False
self.dpstate = False
self.udpstate = False
self.deck = list(self.build.deck)
shuffle(self.deck)
for i in range(7):
self.draw()
def draw(self):
if len(self.hand) < 8:
if self.deck:
self.hand.append(self.deck.pop())
def canplay(self, card):
if card.name == 'fractal' and not self.dragons:
return False
return self.q[card.element] >= card.cost
def play(self, idx):
card = self.hand.pop(idx)
self.q[card.element] -= card.cost
getattr(self, card.name)()
def sov(self):
self.sovs += 1
def dragon(self):
self.dragons += 1
def dim(self):
self.dims = 3
def vagger(self):
self.vagger = True
def aepend(self):
self.ap += 1
def aependup(self):
self.uap += 1
def dapend(self):
self.dp += 1
def dapendup(self):
self.udp += 1
def dark(self):
self.dm += 1
def fractal(self):
while len(self.hand) < 8:
self.hand.append(dragon)
def playturn(self):
for i in range(len(self.hand)-1, -1, -1):
card = self.hand[i]
if card.cost <= 0:
self.play(i)
bolts = siphons = 0
for i in range(len(self.hand)-1, -1, -1):
if card.name == 'siphon' and self.canplay(card):
siphons += 1
if card.name == 'bolt' and self.canplay(card):
bolts += 1
"TODO: handle multiple siphons cost/damage properly"
if ((self.q[Dark]//10)*2+2)*siphons + bolts*5 >= self.hp:
return True
for i in range(len(self.hand)-1, -1, -1):
card = self.hand[i]
if card.name == 'sov' and self.canplay(card):
self.play(i)
if len(self.deck) <= 18:
for i in range(len(self.hand)-1, -1, -1):
card = self.hand[i]
if card.name == 'dim' and self.canplay(card):
self.play(i)
self.hp -= self.sovs*(3 if self.build.mark == Dark else 2)
if self.ap:
self.q[self.build.mark if self.apstate else Aether] += self.ap
self.apstate ^= True
if self.uap:
self.q[self.build.mark if self.uapstate else Aether] += self.uap
self.uapstate ^= True
if self.dp:
self.q[self.build.mark if self.dpstate else Aether] += self.dp
self.dpstate ^= True
if self.udp:
self.q[self.build.mark if self.udpstate else Aether] += self.udp
self.udpstate ^= True
self.q[Dark] += self.dm
#"""
build = Deck(Aether,
dim,dim,dim,dim,dim,
sov,sov,sov,sovup,sovup,
bolt,bolt,bolt,bolt,siphon,
dapill, dapill, dapill, dapill,
dapendup, dapendup, dapendup, dapendup, dapendup, dapendup,
dragon, fractal, vagger)
"""
build = Deck(Dark,
dim,dim,dim,dim,dim,
sov,sov,sov,sovup,sovup,
bolt,bolt,bolt,bolt,siphon,
aepend, aepend, aepend, aepend, aepend,
aependup, aependup, aependup, aependup,
dapill,
dragon, fractal, vagger)
#"""
pl = Player(build)
turns = []
first = False
for i in range(1000):
pl.begin()
if not first:
plies = 1
pl.draw()
else:
plies = 0
while True:
if pl.playturn():
turns.append((plies, *pl.q))
break
if len(pl.hand) == 8:
del pl.hand[0]
if not pl.deck:
turns.append((99, *pl.q))
break
pl.draw()
plies += 2
turns.sort(key=lambda x:x[0])
print(turns[len(turns)//3], turns[len(turns)//2], turns[len(turns)//3*2])