summaryrefslogtreecommitdiff
path: root/src/Actions.java
blob: 57540aba30fc357d0c5b0ee3c12cda7599228e7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

package src;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

class Actions implements KeyListener {
    String cheat="";
    char pressKey =' ';
    
    public void Actions(){}
    @Override
    public void keyTyped(KeyEvent e) {
    }

    @Override
    public void keyReleased(KeyEvent event) {
    }

    @Override
    public void keyPressed(KeyEvent event) {
    
        if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
            isThere('a');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
            isThere('w');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
            isThere('e');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
            isThere('r');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
            isThere('t');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
            isThere('y');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
            isThere('u');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
            isThere('i');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
            isThere('o');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
            isThere('p');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
            isThere('s');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
            isThere('d');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
            isThere('f');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
            isThere('g');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
            isThere('h');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
            isThere('j');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
            isThere('k');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
            isThere('l');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
            isThere('z');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
            isThere('c');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
            isThere('b');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
            isThere('n');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
            isThere('m');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
            hungryCheat('1');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
            hungryCheat('2');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
            hungryCheat('3');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
            hungryCheat('4');
        }
        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
            resetCheat();
        }
        
    }
    public char getKey () {
        return pressKey;
    }
    public String getCheat(){
        return cheat;
    }
    
    private void isThere(char c){
        // Nie wiem czemu od razu nie przekazalem duzej litery...
        pressKey=Character.toUpperCase(c);
        resetCheat();
    }
    private void hungryCheat(char c){
        String s =Character.toString(c);
        cheat += s;
    }
    public void resetCheat(){
        cheat="";
    }
}