-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
50 lines (35 loc) · 723 Bytes
/
main.js
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
require.config({
baseUrl: '.',
paths: {
'action': 'action',
'player': 'player',
'sword': 'sword',
'sommonlist': 'sommon_list',
'sommon': 'sommon'
}
});
require(['action', 'player'],
function(Action, Player) {
// Prototype
Player.prototype = Object.create(Action);
// Constructor
var p1 = new Player('Roy');
var p2 = new Player('Moss');
// Singleton
me.getSword();
// Facade
me.move({x: 100, y: 200});
// Decorator
me.enchant('weapon');
me.attack();
// Factory and Mixin
me.summon('wraith');
// Command
me.summonCommand('move', 100, 200);
// Pub/Sub
me.spiritControl('move', p2.move);
// Pub/Sub
me.spiritCommand('move', 100, 200);
// Command
me.summonCommand('attack');
});