Newer
Older
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
// @flow
import Adjective from './Adjective'
export type ImageOptions = {
text: string,
entity?: string,
}
export default class Noun {
adjectives: Set<Adjective>
textImage: string
entityImage: string
meta = {}
static async createDefaultTextNoun() {
const text = new Noun({ text: '/text-text.png' })
const pushData = await Adjective.resolveInteractionSource({ type: 'internal', data: 'adjectives/push' })
const push = new Adjective('push', pushData)
text.adjectives.add(push)
text.meta.defaultTextNoun = true
return text
}
constructor(images: ImageOptions) {
this.textImage = images.text
this.entityImage = images.entity
this.adjectives = new Set()
}
async interact(otherNoun: Noun, ownLocation: [number, number], previousLocation: [number, number]) {
const otherAdjectives = otherNoun.adjectives
console.log(this.adjectives)
outer: for (const adjective of this.adjectives) {
for (const other of otherAdjectives) {
console.log(adjective)
const outcome = await adjective.interact(other, ownLocation, previousLocation)
return outcome
//
// console.log(adjective.id, other.id, outcome)
// switch (outcome) {
// case "stop":
// break outer
// case "destroy-self":
// console.log("DESTROY_SELF")
// break outer
// case "destroy-other":
// console.log("DESTORY_OTHER")
// break outer
// case "destroy-both":
// console.log("DESTROY_BOTH")
// break outer
// case "is-moved":
// console.log("MOVE_BOTH")
// break outer
// }
}
}
}
clear() {
this.set([])
}
set(adjectives) {
this.adjectives = new Set(adjectives)
}
add(adjective) {
this.adjectives.add(adjective)
}
}