GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Game.game_loop()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
c 3
b 0
f 0
dl 0
loc 19
rs 9.4285
1
import time
2
import random
3
from lib.scorer import Scorer
4
5
6
class Game(object):
7
    def __init__(self, difficulty):
8
        self.nodes = {}
9
        self.difficulty = difficulty
10
        self.scorer = Scorer(self.difficulty)
11
        self.active_nodes = []
12
13
    def multi_player(self, nodes):
14
        self.nodes = nodes
15
16
    def single_player(self, nodes):
17
        self.nodes = nodes
18
        self.game_loop()
19
20
    def start_game(self): pass
21
22
    def get_random_node(self):
23
        nodes = list(self.nodes.keys())
24
        available = list(set(nodes) - set(self.active_nodes))
25
26
        return random.choice(available) if available else available
27
28
    def game_loop(self):
29
        start_time = time.time()
30
        end_time = start_time + (60 * 1)
31
32
        while (end_time - start_time) > 0:
33
            node = self.get_random_node()
34
            if node:
35
                self.nodes[node].activate()
36
                print(str(node) + ' activated!')
37
38
                # self.active_nodes.append(node)
39
                time.sleep(3)
40
41
                self.nodes[node].deactivate()
42
                print(str(node) + ' de-activated!')
43
            else:
44
                print('no nodes left!')
45
                # exit()
46
            time.sleep(3)
47
48
49