ultimate_tictactoe/player.js

56 lines
870 B
JavaScript
Raw Permalink Normal View History

2019-03-06 12:11:43 +01:00
class Player
{
2019-03-10 00:29:15 +01:00
constructor(name, r,g,b)
2019-03-06 12:11:43 +01:00
{
this.name = name;
2019-03-10 00:29:15 +01:00
this.r = r;
this.g = g;
this.b = b;
this.id = name;
2019-03-06 12:11:43 +01:00
}
set_name(name)
{
this.name = name;
2019-03-10 00:29:15 +01:00
this.id = name; // TODO: distinguish between name and id
2019-03-06 12:11:43 +01:00
}
2019-03-10 00:29:15 +01:00
set_color(r,g,b)
2019-03-06 12:11:43 +01:00
{
2019-03-10 00:29:15 +01:00
this.r = r;
this.g = g;
this.b = b;
2019-03-06 12:11:43 +01:00
}
get_name()
{
return this.name;
}
get_id()
{
return this.id;
2019-03-06 12:11:43 +01:00
}
get_color()
{
2019-03-10 00:29:15 +01:00
return "rgb(" + this.r + "," + this.g + "," + this.b + ")";
}
2019-03-29 12:47:49 +01:00
get_color_with_alpha(alpha)
{
return "rgba(" + this.r + "," + this.g + "," + this.b + "," + alpha + ")";
}
2019-03-10 00:29:15 +01:00
get_color_values()
{
var col = {
r: this.r,
g: this.g,
b: this.b
};
return col;
2019-03-06 12:11:43 +01:00
}
}