2021-08-10 09:09:41 +03:00

256 lines
10 KiB
Python

import re
from typing import NamedTuple
from erepublik.constants import COUNTRIES
__all__ = ["events", COUNTRIES, "FLAGS", "UTF_FLAG"]
region = r"[\w\(\)\-& ']+"
country = r"(Resistance force of )?[\w\(\)\- ]+"
citizen = r"[\w\(\)\-\. \d]+"
class EventKind(NamedTuple):
name: str
regex: re.Pattern
format: str
events = [
EventKind("Region attacked", re.compile(rf"(?P<invader>{country}) attacked (?P<region>{region}), (?P<defender>{country})"), "{invader} attacked {defender} ({region})"),
EventKind(
"Region secured",
re.compile(rf"(?P<region>{region}) was secured by (?P<defender>{country}) in the war versus (?P<invader>{country})?"),
"{defender} defended {invader}'s attack ({region})",
),
EventKind(
"Region conquered",
re.compile(rf"(?P<region>{region}) was conquered by (?P<invader>{country}) in the war versus (?P<defender>{country})"),
"{invader} conquered {region} from {defender}",
),
EventKind("War declared", re.compile(rf"(?P<invader>{country}) declared war on (?P<defender>{country})"), "{invader} declared war against {defender}"),
EventKind(
"War declaration",
re.compile(rf"President of (?P<invader>{country}) proposed a war declaration against (?P<defender>{country})"),
"{invader} proposed a war declaration on {defender}",
),
EventKind(
"War rejected", re.compile(rf"The proposal for declaring war against (?P<defender>{country}) was rejected."), "{current_country} rejected war declaration on {defender}"
),
EventKind("MPP proposed", re.compile(rf"President of (?P<country>{country}) proposed an alliance with (?P<partner>{country})"), "{country} proposed MPP with {partner}"),
EventKind("MPP approved", re.compile(rf"(?P<country>{country}) signed an alliance with (?P<partner>{country})"), "{country} signed a MPP with {partner}"),
EventKind(
"MPP rejected", re.compile(rf"The alliance between (?P<country>{country}) and (?P<partner>{country}) was rejected"), "MPP between {country} and {partner} was rejected"
),
EventKind(
"Airstrike proposed",
re.compile(rf"President of (?P<invader>{country}) proposed an airstrike against (?P<defender>{country})"),
"{invader} proposed an airstrike against {defender}",
),
EventKind("Airstrike approved", re.compile(rf"(?P<invader>{country}) prepares an airstrike on (?P<defender>{country})"), "{invader} approved an airstrike against {defender}"),
EventKind("Airstrike rejected", re.compile(rf"The airstrike on (?P<defender>{country}) was rejected"), "{current_country} rejected the airstrike against {defender}"),
EventKind(
"NE proposed",
re.compile(rf"(?P<invader>{country}) has declared (?P<defender>{country}) as a Natural Enemy"),
"{invader} proposed Natural Enemy declaration against {defender}",
),
EventKind("NE approved", re.compile(rf"(?P<defender>{country}) has been proposed as Natural Enemy"), "{current_country} declared {defender} as Natural Enemy"),
EventKind("NE rejected", re.compile(rf"(?P<defender>{country}) as new Natural Enemy proposal has been rejected"), "{current_country} rejected {defender} as Natural Enemy"),
EventKind("NE stopped", re.compile(rf"(?P<defender>{country}) is no longer a Natural Enemy for (?P<invader>{country})"), "{invader} removed Natural Enemy from {defender}"),
EventKind("NE cleared", re.compile(rf"(?P<country>{country}) no longer has a Natural Enemy"), "{country} no longer has a Natural Enemy"),
EventKind("NE reset", re.compile("No Natural Enemy law has been proposed."), "{current_country} has proposed to clear Natural Enemy"),
EventKind(
"Peace proposal",
re.compile(rf"President of (?P<defender>{country}) proposed a peace in the war against (?P<invader>{country})"),
"{defender} proposed peace against {invader}",
),
EventKind("Peace proposal", re.compile(rf"(?P<defender>{country}) proposed peace in the war against (?P<invader>{country})"), "{defender} proposed peace against {invader}"),
EventKind("Peace approved", re.compile(rf"(?P<invader>{country}) signed a peace treaty with (?P<defender>{country})"), "{invader} and {defender} is not in peace"),
EventKind(
"Peace rejected",
re.compile(rf"The proposed peace treaty between (?P<defender>{country}) and (?P<invader>{country}) was rejected"),
"{defender} and {invader} did not sign a peace treaty",
),
EventKind(
"Embargo proposed", re.compile(rf"President of (?P<major>{country}) proposed to stop the trade with (?P<minor>{country})"), "{major} proposed trade embargo against {minor}"
),
EventKind("Embargo approved", re.compile(rf"(?P<major>{country}) stopped trading with (?P<minor>{country})"), "{major} declared trade ambargo against {minor}"),
EventKind("Donation proposed", re.compile(rf"A congress donation to (?P<org>{citizen}) was proposed"), "{current_country} proposed a donation to {org}"),
EventKind("Donation approved", re.compile(rf"(?P<country>{country}) made a donation to (?P<org>{citizen})"), "{current_country} approved a donation to {org}"),
EventKind("Donation rejected", re.compile(rf"The proposal for a congress donation to (?P<org>{citizen}) was rejected"), "{current_country} rejected a donation to {org}"),
EventKind("RW started", re.compile(rf"A resistance has started in (?P<region>{region})"), "Resistance war was opened in {region} ({current_country})"),
EventKind(
"Res Concession",
re.compile(
rf"A Resource Concession law to //www.erepublik.com<b>(?P<target>{country})</b> "
+ rf'<a href="(?P<link>((https?:)?//www\.erepublik\.com)?/en/main/law/(?P<source>{country}/\d+))">has been (?P<result>.*?)</a>'
),
"Resource Concession law between {current_country} and {target} has been {result}",
),
EventKind(
"CP impeachment", re.compile(rf"A president impeachment against (?P<cp>{citizen}) was proposed"), "Impeachment against {cp} president of {current_country} was proposed"
),
EventKind("CP impeachment", re.compile("The president impeachment proposal has been rejected"), "Impeachment against president of {current_country} was rejected"),
EventKind("Minimum Wage", re.compile("A new minimum wage was proposed"), "A new minimum wage in {current_country} was proposed"),
EventKind("Minimum Wage", re.compile("The proposal for a minimum wage change was rejected"), "The new minimum wage proposal in {current_country} was rejected"),
EventKind("WorkTax", re.compile(rf"(?P<country>{country}) now has a new Work Tax"), "{country} has new Work Tax"),
EventKind("WorkTax", re.compile("A new Work Tax was proposed"), "{country} proposed a new Work Tax"),
EventKind("WorkTax", re.compile("The proposal for a new Work Tax was rejected"), "{country} rejected new Work Tax"),
EventKind("Product Tax", re.compile(r"Taxes for (?P<product>[\w ]+) changed"), "{current_country} changed taxes for {product}"),
EventKind("Product Tax", re.compile(r"Tax proposal of tax changes for (?P<product>[\w ]+) were rejected"), "{current_country} rejected new taxes for {product}"),
EventKind("Product Tax", re.compile(r"New taxes for (?P<product>[\w ]+) were proposed"), "{current_country} proposed new taxes for {product}"),
]
UTF_FLAG = {
1: "🇷🇴",
9: "🇧🇷",
10: "🇮🇹",
11: "🇫🇷",
12: "🇩🇪",
13: "🇭🇺",
14: "🇨🇳",
15: "🇪🇸",
23: "🇨🇦",
24: "🇺🇸",
26: "🇲🇽",
27: "🇦🇷",
28: "🇻🇪",
29: "🇬🇧",
30: "🇨🇭",
31: "🇳🇱",
32: "🇧🇪",
33: "🇦🇹",
34: "🇨🇿",
35: "🇵🇱",
36: "🇸🇰",
37: "🇳🇴",
38: "🇸🇪",
39: "🇫🇮",
40: "🇺🇦",
41: "🇷🇺",
42: "🇧🇬",
43: "🇹🇷",
44: "🇬🇷",
45: "🇯🇵",
47: "🇰🇷",
48: "🇮🇳",
49: "🇮🇩",
50: "🇦🇺",
51: "🇿🇦",
52: "🇲🇩",
53: "🇵🇹",
54: "🇮🇪",
55: "🇩🇰",
56: "🇮🇷",
57: "🇵🇰",
58: "🇮🇱",
59: "🇹🇭",
61: "🇸🇮",
63: "🇭🇷",
64: "🇨🇱",
65: "🇷🇸",
66: "🇲🇾",
67: "🇵🇭",
68: "🇸🇬",
69: "🇧🇦",
70: "🇪🇪",
71: "🇱🇻",
72: "🇱🇹",
73: "🇰🇵",
74: "🇺🇾",
75: "🇵🇾",
76: "🇧🇴",
77: "🇵🇪",
78: "🇨🇴",
79: "🇲🇰",
80: "🇲🇪",
81: "🇹🇼",
82: "🇨🇾",
83: "🇧🇾",
84: "🇳🇿",
164: "🇸🇦",
165: "🇪🇬",
166: "🇦🇪",
167: "🇦🇱",
168: "🇬🇪",
169: "🇦🇲",
170: "🇳🇬",
171: "🇨🇺",
}
FLAGS = {
1: "flag_ro",
9: "flag_br",
10: "flag_it",
11: "flag_fr",
12: "flag_de",
13: "flag_hu",
14: "flag_cn",
15: "flag_es",
23: "flag_ca",
24: "flag_us",
26: "flag_mx",
27: "flag_ar",
28: "flag_ve",
29: "flag_gb",
30: "flag_ch",
31: "flag_nl",
32: "flag_be",
33: "flag_at",
34: "flag_cz",
35: "flag_pl",
36: "flag_sk",
37: "flag_no",
38: "flag_se",
39: "flag_fi",
40: "flag_ua",
41: "flag_ru",
42: "flag_bg",
43: "flag_tr",
44: "flag_gr",
45: "flag_jp",
47: "flag_kr",
48: "flag_in",
49: "flag_id",
50: "flag_au",
51: "flag_za",
52: "flag_md",
53: "flag_pt",
54: "flag_ie",
55: "flag_de",
56: "flag_ir",
57: "flag_pk",
58: "flag_il",
59: "flag_th",
61: "flag_si",
63: "flag_hr",
64: "flag_cl",
65: "flag_rs",
66: "flag_my",
67: "flag_ph",
68: "flag_sg",
69: "flag_ba",
70: "flag_ee",
71: "flag_lv",
72: "flag_lt",
73: "flag_kp",
74: "flag_uy",
75: "flag_py",
76: "flag_bo",
77: "flag_pe",
78: "flag_co",
79: "flag_mk",
80: "flag_me",
81: "flag_tw",
82: "flag_cy",
83: "flag_by",
84: "flag_nz",
164: "flag_sa",
165: "flag_eg",
166: "flag_ae",
167: "flag_al",
168: "flag_ge",
169: "flag_am",
170: "flag_ng",
171: "flag_cu",
}