BelligerentConstant.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 13
rs 9.85
c 0
b 0
f 0
cc 1
nop 5
1
from typing import Optional
2
3
from candv import Values
4
from candv import VerboseValueConstant
5
from candv import with_constant_class
6
7
from .typing import String
8
9
from ._translations import gettext_lazy as _
10
from ._utils import export
11
12
13
@export
14
class BelligerentConstant(VerboseValueConstant):
15
16
  def __init__(
17
    self,
18
    value:        int,
19
    color:        str,
20
    verbose_name: Optional[String] = None,
21
    help_text:    Optional[String] = None,
22
  ):
23
    super().__init__(
24
      value=value,
25
      verbose_name=verbose_name,
26
      help_text=help_text,
27
    )
28
    self.color = color
29
30
  def merge_into_group(self, group):
31
    super().merge_into_group(group)
32
    group.color = self.color
33
34
  def to_primitive(self, *args, **kwargs):
35
    primitive = super().to_primitive(*args, **kwargs)
36
    primitive['color'] = self.color
37
    return primitive
38
39
40
@export
41
class BELLIGERENTS(with_constant_class(BelligerentConstant), Values):
42
  """
43
  Definitions of belligerents (a.k.a "armies").
44
45
  Extracted from "com.maddox.il2.ai.Army" with colors decoded.
46
47
  """
48
  NONE      = BelligerentConstant(value=0,  color="FFFFFF", verbose_name=_("none"))
49
  RED       = BelligerentConstant(value=1,  color="C00000", verbose_name=_("red"))
50
  BLUE      = BelligerentConstant(value=2,  color="0000C0", verbose_name=_("blue"))
51
  GREEN     = BelligerentConstant(value=3,  color="00C000", verbose_name=_("green"))
52
  GOLD      = BelligerentConstant(value=4,  color="C0C000", verbose_name=_("gold"))
53
  PURPLE    = BelligerentConstant(value=5,  color="C000C0", verbose_name=_("purple"))
54
  AQUA      = BelligerentConstant(value=6,  color="00C0C0", verbose_name=_("aqua"))
55
  MAROON    = BelligerentConstant(value=7,  color="800000", verbose_name=_("maroon"))
56
  NAVY      = BelligerentConstant(value=8,  color="000080", verbose_name=_("navy"))
57
  EMERALD   = BelligerentConstant(value=9,  color="004000", verbose_name=_("emerald"))
58
  OLIVE     = BelligerentConstant(value=10, color="59800C", verbose_name=_("olive"))
59
  MAGENTA   = BelligerentConstant(value=11, color="800080", verbose_name=_("magenta"))
60
  TEAL      = BelligerentConstant(value=12, color="008080", verbose_name=_("teal"))
61
  ORANGE    = BelligerentConstant(value=13, color="E7651A", verbose_name=_("orange"))
62
  TURQUOISE = BelligerentConstant(value=14, color="00A49E", verbose_name=_("turquoise"))
63
  BROWN     = BelligerentConstant(value=15, color="8C6636", verbose_name=_("brown"))
64
  SALAD     = BelligerentConstant(value=16, color="408040", verbose_name=_("salad"))
65