-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.js
More file actions
119 lines (86 loc) · 2.82 KB
/
Copy pathtask.js
File metadata and controls
119 lines (86 loc) · 2.82 KB
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
var task_list;
var no_tasks = 0;
var task_names = ["aliens", "secv8", "popcorn", "odometer", "santa", "kcity", "bacterii2", "robot"];
function taskClass(name, x, y, coding_need, solving_need, boss_need)
{
this.name = name;
this.coding_need = coding_need;
this.solving_need = solving_need;
this.boss_need = boss_need;
this.next_task;
var cell = who_wall_player[x][y];
var img = document.createElement("img");
img.setAttribute("src", "poze/task.png");
img.style.width = "100%";
img.style.height = "100%";
img.style.zIndex = "1";
img.style.position = "relative";
img.onmouseover = function() { show_task_details(this)};
img.onmouseout = function() { erase_task_details(this)};
img.katerinca = this;
cell.appendChild(img);
}
function add_task(x, y, cnt)
{
task_list[cnt] = new taskClass(task_names[get_random(task_names.length)], x, y, get_random(100), get_random(100), get_random(100));
}
function generate_task()
{
var x, y;
for(var step = 0; step < 3* table_cells; step ++)//if after 30 tries, there was no any free cell for putting the new task, skip this step
{
x = get_random(table_cells);
y = get_random(table_cells);
if(is_wall[x][y] == 0 && someone(x, y) == false)
{
add_task(x, y, no_tasks++);
return;
}
}
}
var score = 0;
function update_score()
{
score ++;
var score_board = document.getElementById("score_board");
score_board.innerHTML = "Total score " + score;
print_info(selected);
}
// p.onmouseover = function(){ print_elapse_for_task(this.katerinca, p)};
// p.onmouseout = function(){ erase_elapse_for_task(this.katerinca, p)};
function print_elapse_for_task(task, person, act_node)
{
// if(act_node.childNodes[1].tagName == "DIV")
// return;
var elapse = maximul_between(task.coding_need / person.coding_skill, task.solving_need / person.solving_skill, task.boss_need / person.boss_skill);
var div = document.createElement("div");
div.innerHTML = "elapse time: " + Math.ceil(elapse);
div.style.width = "100px";
div.style.border = "1px solid gray";
div.style.fontSize = "10px";
div.style.position = "relative";
div.style.top = (act_node.style.top) + "px";
act_node.appendChild(div);
// act_node.parentNode.insertBefore(div, act_node.nextSibling);
}
function erase_elapse_for_task(act_node)
{
act_node.removeChild(act_node.childNodes[1]);
}
function show_task_details(node_img)
{
var task = node_img.katerinca;
var string = "C:" + task.coding_need +" S:" + task.solving_need + " B:" + task.boss_need;
var div = document.createElement("div");
div.innerHTML = string;
div.style.width = "20px";
div.style.fontSize = "10px";
div.style.position = "relative";
div.style.background = "white";
div.style.zIndex = "5";
node_img.parentNode.insertBefore(div, node_img.nextSibling);
}
function erase_task_details(node_img)
{
node_img.parentNode.removeChild(node_img.nextSibling);
}