~yandere-dev/yandere/0.1

« back to all changes in this revision

Viewing changes to classes/yandere-user/method.learn_role.php

  • Committer:
  • Date: 2008-12-30 06:01:27 UTC
  • Revision ID: svn-v3-single1-dHJ1bmsvcGhhcm8tbW9kdWxlcy9pcmMteWFuZGVyZQ..:3f858fc8-aa8f-444a-bb42-203473f3994f:trunk%2Fpharo-modules%2Firc-yandere:29
For luke-jr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
        
 
3
        list ($user_id, $role) = $args;
 
4
        
 
5
        $knew_role = isset ($this->known_roles[$user_id]);
 
6
        
 
7
        $this->known_roles[$user_id] = $role;
 
8
        $this->claimed_roles[$user_id] = $role;
 
9
        
 
10
        $user = $this->game->players[$user_id];
 
11
        
 
12
        if (!isset ($this->known_alignments[$user_id]))
 
13
        {
 
14
                $this->known_alignments[$user_id] = isset ($this->server->custom_vars->yandere_yandere_odds[$role]);
 
15
        }
 
16
        
 
17
        // Respond with own role.
 
18
        
 
19
        if ($user_id != $this->user_id && !in_array($role, $this->server->custom_vars->yandere_enemies))
 
20
        {
 
21
                if (!$this->is_enemy)
 
22
                {
 
23
                        $user->claim_role($this->user_id, $this->role);
 
24
                }
 
25
        }
 
26
        
 
27
        if (!$knew_role)
 
28
        {
 
29
                if (!$this->is_enemy)
 
30
                {
 
31
                        // Inform trusted players.
 
32
                        
 
33
                        foreach ($this->game->players as $player_id => $player)
 
34
                        {
 
35
                                if ($player_id == $this->user_id)
 
36
                                {
 
37
                                        // I already know what I know.
 
38
                                        continue;
 
39
                                }
 
40
                                
 
41
                                if (isset ($this->known_alignments[$player_id]) && $this->known_alignments[$player_id] === false)
 
42
                                {
 
43
                                        if (isset ($player->known_alignments[$this->user_id]) && $player->known_alignments[$this->user_id] === false)
 
44
                                        {
 
45
                                                // Mutual trust. The recipient should consider this information as fact.
 
46
                                                
 
47
                                                foreach ($this->known_alignments as $user_id => $role)
 
48
                                                {
 
49
                                                        if (!isset ($player->known_roles[$user_id]))
 
50
                                                        {
 
51
                                                                $player->learn_role($user_id, $role);
 
52
                                                        }
 
53
                                                }
 
54
                                        }
 
55
                                }
 
56
                        }
 
57
                }
 
58
        }
 
59
        
 
60
?>