def do_seasonwin(self, args): """Generate Season winner image (needs db session).\n\tUsage: seasonwin [sprite] """ args = args.strip().split(' ') a = Rooster.select().random(1)[0] if args[0] != '': a = Rooster.get(sprite=args[0]) tkimg.show_img(create_season_winner(a.sprite))
def do_grid(self, args): """Generate Move button grid (needs db session).\n\tUsage: grid [scale=1.0] """ from random import choice args = args.split(' ') scale = 1.0 if args[0] != '': scale = float(args[0]) moves = list(Move.select().random(4)) tkimg.show_img(create_movesgrid(moves, choice(moves), scale=scale))
def post_msg(self, msg, img=None, battle=True, reply=True, pin=False): toot = self.get_toot(battle) if toot: toot.post(msg, img, reply=reply, pin=pin) tweet = self.get_tweet(battle) if tweet: tweet.post(msg, img, reply=reply, pin=pin) print(msg) if self.tk and img: tkimg.show_img(img) self.interaction(5)
def do_highlight(self, args): """Generate presentation image (needs db session).\n\tUsage: highlight [sprite-a] [sprite-b] """ from random import choice args = args.strip().split(' ') a, b = Rooster.select().random(2) if args[0] != '': a = Rooster.get(sprite=args[0]) if len(args) > 1: b = Rooster.get(sprite=args[1]) a.reset() b.reset() tkimg.show_img(create_highlight(a, b, choice([a, b])))
def do_distort(self, args): """Distort sprite using the default mask (needs db session).\n\tUsage: distort [sprite] [mask] """ sprite = '' args = args.strip().split(' ') mask = 'distort-mask.png' if not args[0] in ('', '-'): sprite = args[0] else: sprite = Rooster.select().random(1)[0].sprite if len(args) > 1: mask = args[1] tkimg.show_img(distort_sprite(sprite, mask))
def do_move(self, args): """Generate Move UI button.\n\tUsage: move [ap] attack-name """ args = args.split(' ') has_ap = False try: ap = int(args[0]) has_ap = True except: import random ap = random.randint(0, 30) text = ' '.join(args[1 if has_ap else 0:]) tkimg.show_img(create_movebtn(text, ap, scale=2))
def do_hp(self, args): """Generate HP bar.\n\tUsage: hp [value=0..100] [anchor=left|right] """ import random args = args.strip().split(' ') anchors = {'left': Side.LEFT, 'right': Side.RIGHT} anchor = random.choice(list(anchors.values())) if len(args) > 1: print(args) anc = anchors.get(args[1]) anchor = anc if anc != None else anchor if args[0] == '': value = random.random() else: value = int(args[0].replace('%', '')) / 100 tkimg.show_img( create_hpbar(value, prev=min(value + 0.1, 1), anchor=anchor))
def do_win(self, args): """Generate battle end image (needs db session).\n\tUsage: battle [sprite-a] [sprite-b] """ from random import choice args = args.strip().split(' ') a, b = Rooster.select().random(2) if args[0] != '': a = Rooster.get(sprite=args[0]) if len(args) > 1: b = Rooster.get(sprite=args[1]) a.reset() b.reset() hit = choice([a, b]) kargs = { 'hit': hit, 'hit_type': choice([HitType.HIT, HitType.CRITICAL]), 'done': True, } tkimg.show_img(create_battle_hit(a, b, **kargs))
def do_battle(self, args): """Generate battle image (needs db session).\n\tUsage: battle [sprite-a] [sprite-b] """ from random import choice args = args.strip().split(' ') a, b = Rooster.select().random(2) if args[0] != '': a = Rooster.get(sprite=args[0]) if len(args) > 1: b = Rooster.get(sprite=args[1]) a.reset() b.reset() hit = choice([a, b]) attack = (a if hit != a else b).moves.select().random(1)[0] data = { 'hit': hit, 'hit_type': choice([HitType.HIT, HitType.CRITICAL]), 'attack': attack, } tkimg.show_img(create_battle_hit(a, b, **data))