aboutsummaryrefslogtreecommitdiff
path: root/misc/pla-tracker/main.py
blob: 97b10b9f6c937e1c4cb92163d72827fa749c03ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env nix-shell
#! nix-shell -p python310 -i python

import json
import sqlite3

con = sqlite3.connect("pokemans.db")

help_text = """Pokemon Legends Arceus Pokedex Tracker from Within

Commands:
  catch <id|name>
  complete <id|name>
  see <id|name>
  whatsleft [seen|catch|complete]
"""

print(help_text)

while True:
    command = input("> ")
    command = command.split()

    match command[0]:
        case "help":
            print(help_text)
        case "catch":
            names = map(lambda x: (x,),command[1:])
            cur = con.cursor()
            cur.executemany("UPDATE pokemon SET seen=true, caught=true WHERE name = ?1 COLLATE NOCASE", names)
            con.commit()
        case "complete":
            names = map(lambda x: (x,),command[1:])
            cur = con.cursor()
            cur.executemany("UPDATE pokemon SET seen=true, caught=true, complete=true WHERE name = ?1 COLLATE NOCASE", names)
            con.commit()
        case "see":
            names = map(lambda x: (x,),command[1:])
            cur = con.cursor()
            cur.executemany("UPDATE pokemon SET seen=true WHERE name = ?1 COLLATE NOCASE", names)
            con.commit()
        case "whatsleft":
            if len(command) == 1:
                cur = con.cursor()
                for pokemon in cur.execute("SELECT dex_id, name FROM pokemon WHERE caught = 0"):
                    print("%s: %s" % (pokemon[0], pokemon[1]))
                continue
            kind = command[1]