Exemplo n.º 1
0
def battle(self, attacker, aa, ad, bd0, tloc, da, dd, bd1):
	loc = LOCATION((attacker >> 8) & 0xff)
	seq = (attacker >> 16) & 0xff
	c2 = attacker & 0xff
	card = self.get_card(c2, loc, seq)
	tc = tloc & 0xff
	tl = LOCATION((tloc >> 8) & 0xff)
	tseq = (tloc >> 16) & 0xff
	if tloc:
		target = self.get_card(tc, tl, tseq)
	else:
		target = None
	for pl in self.players + self.watchers:
		if card.type & TYPE.LINK:
			attacker_points = "%d"%aa
		else:
			attacker_points = "%d/%d"%(aa, ad)

		if target:
			if target.type & TYPE.LINK:
				defender_points = "%d"%da
			else:
				defender_points = "%d/%d"%(da, dd)

		if target:
			pl.notify(pl._("%s (%s) attacks %s (%s)") % (card.get_name(pl), attacker_points, target.get_name(pl), defender_points))
		else:
			pl.notify(pl._("%s (%s) attacks") % (card.get_name(pl), attacker_points))
Exemplo n.º 2
0
def msg_attack(self, data):
    data = io.BytesIO(data[1:])
    attacker = self.read_u32(data)
    ac = attacker & 0xff
    al = LOCATION((attacker >> 8) & 0xff)
    aseq = (attacker >> 16) & 0xff
    apos = POSITION((attacker >> 24) & 0xff)
    target = self.read_u32(data)
    tc = target & 0xff
    tl = LOCATION((target >> 8) & 0xff)
    tseq = (target >> 16) & 0xff
    tpos = POSITION((target >> 24) & 0xff)
    self.cm.call_callbacks('attack', ac, al, aseq, apos, tc, tl, tseq, tpos)
    return data.read()
Exemplo n.º 3
0
def msg_become_target(self, data):
    data = io.BytesIO(data[1:])
    u = self.read_u8(data)
    target = self.read_u32(data)
    tc = target & 0xff
    tl = LOCATION((target >> 8) & 0xff)
    tseq = (target >> 16) & 0xff
    tpos = POSITION((target >> 24) & 0xff)
    self.cm.call_callbacks('become_target', tc, tl, tseq)
    return data.read()
Exemplo n.º 4
0
def msg_flipsummoning(self, data):
    data = io.BytesIO(data[1:])
    code = self.read_u32(data)
    location = self.read_u32(data)
    c = location & 0xff
    loc = LOCATION((location >> 8) & 0xff)
    seq = (location >> 16) & 0xff
    card = self.get_card(c, loc, seq)
    self.cm.call_callbacks('flipsummoning', card)
    return data.read()
Exemplo n.º 5
0
def msg_pos_change(self, data):
	data = io.BytesIO(data[1:])
	code = self.read_u32(data)
	card = Card(code)
	card.controller = self.read_u8(data)
	card.location = LOCATION(self.read_u8(data))
	card.sequence = self.read_u8(data)
	prevpos = POSITION(self.read_u8(data))
	card.position = POSITION(self.read_u8(data))
	self.cm.call_callbacks('pos_change', card, prevpos)
	return data.read()
Exemplo n.º 6
0
def msg_sort_card(self, data):
    data = io.BytesIO(data[1:])
    player = self.read_u8(data)
    size = self.read_u8(data)
    cards = []
    for i in range(size):
        card = Card(self.read_u32(data))
        card.controller = self.read_u8(data)
        card.location = LOCATION(self.read_u8(data))
        card.sequence = self.read_u8(data)
        cards.append(card)
    self.cm.call_callbacks('sort_card', player, cards)
    return data.read()
Exemplo n.º 7
0
def msg_select_sum(self, data):
    data = io.BytesIO(data[1:])
    mode = self.read_u8(data)
    player = self.read_u8(data)
    val = self.read_u32(data)
    select_min = self.read_u8(data)
    select_max = self.read_u8(data)
    count = self.read_u8(data)
    must_select = []
    for i in range(count):
        code = self.read_u32(data)
        card = Card(code)
        card.controller = self.read_u8(data)
        card.location = LOCATION(self.read_u8(data))
        card.sequence = self.read_u8(data)
        param = self.read_u32(data)
        card.param = (
            param & 0xff,
            param >> 16,
        )
        must_select.append(card)
    count = self.read_u8(data)
    select_some = []
    for i in range(count):
        code = self.read_u32(data)
        card = Card(code)
        card.controller = self.read_u8(data)
        card.location = LOCATION(self.read_u8(data))
        card.sequence = self.read_u8(data)
        param = self.read_u32(data)
        card.param = (
            param & 0xff,
            param >> 16,
        )
        select_some.append(card)
    self.cm.call_callbacks('select_sum', mode, player, val, select_min,
                           select_max, must_select, select_some)
    return data.read()
Exemplo n.º 8
0
def msg_confirm_cards(self, data):
    data = io.BytesIO(data[1:])
    player = self.read_u8(data)
    size = self.read_u8(data)
    cards = []
    for i in range(size):
        code = self.read_u32(data)
        c = self.read_u8(data)
        l = LOCATION(self.read_u8(data))
        s = self.read_u8(data)
        card = self.get_card(c, l, s)
        cards.append(card)
    self.cm.call_callbacks('confirm_cards', player, cards)
    return data.read()
Exemplo n.º 9
0
def msg_confirm_decktop(self, data):
    cards = []
    data = io.BytesIO(data[1:])
    player = self.read_u8(data)
    count = self.read_u8(data)
    for i in range(count):
        code = self.read_u32(data)
        if code & 0x80000000:
            code = code ^ 0x80000000  # don't know what this actually does
        card = Card(code)
        card.controller = self.read_u8(data)
        card.location = LOCATION(self.read_u8(data))
        card.sequence = self.read_u8(data)
        cards.append(card)

    self.cm.call_callbacks('confirm_decktop', player, cards)
    return data.read()
Exemplo n.º 10
0
def msg_select_tribute(self, data):
	data = io.BytesIO(data[1:])
	player = self.read_u8(data)
	cancelable = self.read_u8(data)
	min = self.read_u8(data)
	max = self.read_u8(data)
	size = self.read_u8(data)
	cards = []
	for i in range(size):
		code = self.read_u32(data)
		card = Card(code)
		card.controller = self.read_u8(data)
		card.location = LOCATION(self.read_u8(data))
		card.sequence = self.read_u8(data)
		card.position = self.get_card(card.controller, card.location, card.sequence).position
		card.release_param = self.read_u8(data)
		cards.append(card)
	self.cm.call_callbacks('select_tribute', player, cancelable, min, max, cards)
	return data.read()
Exemplo n.º 11
0
def msg_counters(self, data):
    data = io.BytesIO(data[0:])

    msg = self.read_u8(data)

    ctype = self.read_u16(data)

    pl = self.read_u8(data)

    loc = LOCATION(self.read_u8(data))

    seq = self.read_u8(data)

    count = self.read_u16(data)

    card = self.get_card(pl, loc, seq)

    self.cm.call_callbacks('counters', card, ctype, count, msg == 101)

    return data.read()