Add Direction.all() that returns an iterator that produces all the Direction values
This commit is contained in:
parent
1247617b87
commit
1cd45d366b
2 changed files with 13 additions and 12 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Tuple, overload
|
||||
from typing import Any, Iterator, overload
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Point:
|
||||
|
|
@ -47,6 +47,17 @@ class Direction:
|
|||
West = Vector(-1, 0)
|
||||
NorthWest = Vector(-1, -1)
|
||||
|
||||
@classmethod
|
||||
def all(cls) -> Iterator['Direction']:
|
||||
yield Direction.North
|
||||
yield Direction.NorthEast
|
||||
yield Direction.East
|
||||
yield Direction.SouthEast
|
||||
yield Direction.South
|
||||
yield Direction.SouthWest
|
||||
yield Direction.West
|
||||
yield Direction.NorthWest
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Size:
|
||||
width: int = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue