Skip to content

Commit 11d946b

Browse files
committed
1.6.1
1 parent 3cb8b8a commit 11d946b

File tree

3 files changed

+70
-71
lines changed

3 files changed

+70
-71
lines changed

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Xpdustry DominationPlugin",
44
"author": "Phinner",
55
"description": "Capture the zones to win!",
6-
"version": "1.6",
6+
"version": "1.6.1",
77
"minGameVersion": "105",
88
"hidden": true,
99
"java": true,

src/main/java/fr/xpdustry/domination/DominationMap.java

+60-60
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,64 @@ public class DominationMap implements Iterable<Zone>{
2222
private float gameDuration = 10F;
2323
private float showdownDuration = 3F;
2424
private boolean immortalCore = true;
25-
private final ArrayList<Zone> zones = new ArrayList<>();
25+
private final List<Zone> zones = new ArrayList<>();
2626

2727
private static final Seq<Effect> effects = Seq.with(Fx.mine, Fx.mineBig, Fx.mineHuge);
2828

2929
public void update(){
3030
zones.forEach(z -> z.update(this));
3131
}
3232

33+
public float[] createZoneCircle(){
34+
return Geometry.regPoly((int)(Mathf.pi * zoneRadius), zoneRadius);
35+
}
36+
37+
public void drawZoneCircles(){
38+
float[] circle = createZoneCircle();
39+
40+
zones.forEach(z -> {
41+
Geometry.iteratePolygon((cx, cy) -> {
42+
Call.effect(effects.random(), (cx + z.getX()) * Vars.tilesize, (cy + z.getY()) * Vars.tilesize, 0, z.getTeam().color);
43+
}, circle);
44+
});
45+
}
46+
47+
public void drawZoneCircles(NetConnection con){
48+
float[] circle = createZoneCircle();
49+
50+
zones.forEach(z -> {
51+
Geometry.iteratePolygon((cx, cy) -> {
52+
Call.effect(con, effects.random(), (cx + z.getX()) * Vars.tilesize, (cy + z.getY()) * Vars.tilesize, 0, z.getTeam().color);
53+
}, circle);
54+
});
55+
}
56+
57+
public void drawZoneCenters(){
58+
zones.forEach(z -> {
59+
Call.effect(Fx.unitLand, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize, 0, z.getTeam().color);
60+
});
61+
}
62+
63+
public void drawZoneCenters(NetConnection con){
64+
zones.forEach(z -> {
65+
Call.effect(con, Fx.unitLand, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize, 0, z.getTeam().color);
66+
});
67+
}
68+
69+
public void drawZoneTexts(float lifetime){
70+
zones.forEach(z -> {
71+
String percent = Strings.format("[#@]@%", z.getTeam().color, Strings.fixed(z.getPercent(), 0));
72+
Call.label(percent, lifetime, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize);
73+
});
74+
}
75+
76+
public void drawZoneTexts(NetConnection con, float lifetime){
77+
zones.forEach(z -> {
78+
String percent = Strings.format("[#@]@%", z.getTeam().color, Strings.fixed(z.getPercent(), 0));
79+
Call.label(con, percent, lifetime, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize);
80+
});
81+
}
82+
3383
public int getZoneRadius(){
3484
return zoneRadius;
3585
}
@@ -66,6 +116,15 @@ public void setGameDuration(float gameDuration){
66116
this.gameDuration = gameDuration;
67117
}
68118

119+
public float getShowdownDuration(){
120+
return showdownDuration;
121+
}
122+
123+
public void setShowdownDuration(float showdownDuration){
124+
if(showdownDuration < 0) throw new IllegalArgumentException("The showdown duration is negative: " + showdownDuration);
125+
this.showdownDuration = showdownDuration;
126+
}
127+
69128
public boolean hasImmortalCore(){
70129
return immortalCore;
71130
}
@@ -105,65 +164,6 @@ public Zone getZone(int x, int y){
105164
return null;
106165
}
107166

108-
public float getShowdownDuration(){
109-
return showdownDuration;
110-
}
111-
112-
public void setShowdownDuration(float showdownDuration){
113-
if(showdownDuration < 0) throw new IllegalArgumentException("The showdown duration is negative: " + showdownDuration);
114-
this.showdownDuration = showdownDuration;
115-
}
116-
117-
public void drawZoneCircles(){
118-
float[] circle = createZoneCircle();
119-
120-
zones.forEach(z -> {
121-
Geometry.iteratePolygon((cx, cy) -> {
122-
Call.effect(effects.random(), (cx + z.getX()) * Vars.tilesize, (cy + z.getY()) * Vars.tilesize, 0, z.getTeam().color);
123-
}, circle);
124-
});
125-
}
126-
127-
public void drawZoneCircles(NetConnection con){
128-
float[] circle = createZoneCircle();
129-
130-
zones.forEach(z -> {
131-
Geometry.iteratePolygon((cx, cy) -> {
132-
Call.effect(con, effects.random(), (cx + z.getX()) * Vars.tilesize, (cy + z.getY()) * Vars.tilesize, 0, z.getTeam().color);
133-
}, circle);
134-
});
135-
}
136-
137-
public void drawZoneCenters(){
138-
zones.forEach(z -> {
139-
Call.effect(Fx.unitLand, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize, 0, z.getTeam().color);
140-
});
141-
}
142-
143-
public void drawZoneCenters(NetConnection con){
144-
zones.forEach(z -> {
145-
Call.effect(con, Fx.unitLand, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize, 0, z.getTeam().color);
146-
});
147-
}
148-
149-
public void drawZoneTexts(float lifetime){
150-
zones.forEach(z -> {
151-
String percent = Strings.format("[#@]@%", z.getTeam().color, Strings.fixed(z.getPercent(), 0));
152-
Call.label(percent, lifetime, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize);
153-
});
154-
}
155-
156-
public void drawZoneTexts(NetConnection con, float lifetime){
157-
zones.forEach(z -> {
158-
String percent = Strings.format("[#@]@%", z.getTeam().color, Strings.fixed(z.getPercent(), 0));
159-
Call.label(con, percent, lifetime, z.getX() * Vars.tilesize, z.getY() * Vars.tilesize);
160-
});
161-
}
162-
163-
public float[] createZoneCircle(){
164-
return Geometry.regPoly((int)(Mathf.pi * zoneRadius), zoneRadius);
165-
}
166-
167167
@Override
168168
public Iterator<Zone> iterator(){
169169
return zones.listIterator();

src/main/java/fr/xpdustry/domination/DominationPlugin.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ public void init(){
7373

7474
if(timers.get(COUNTDOWN_TIMER, (showdown ? getCurrentMap().getShowdownDuration() : getCurrentMap().getGameDuration()) * Time.toMinutes)){
7575
List<Team> winners = getWinners();
76-
if(winners.size() == 0){
77-
Events.fire(new GameOverEvent(Team.derelict));
78-
}else if(winners.size() == 1){
79-
Events.fire(new GameOverEvent(winners.get(0)));
80-
}else{
81-
triggerShowdown(winners);
76+
77+
switch(winners.size()){
78+
case 0: triggerShowdown(Vars.state.teams.getActive().map(d -> d.team).list()); break;
79+
case 1: Events.fire(new GameOverEvent(winners.get(0))); break;
80+
default: triggerShowdown(winners);
8281
}
8382
}
8483
}
@@ -99,15 +98,15 @@ public void init(){
9998
// Leaderboard
10099
leaderboard.each((team, percent) -> {
101100
String percentString = Strings.fixed(percent / getCurrentMap().getZoneNumber(), 2);
102-
builder.append(Strings.format("\n[#@]@[] > @%", team.color, team == Team.derelict ? "unclaimed" : team.name, percentString));
101+
builder.append(Strings.format("\n[#@]@[] > @%", team.color, team == Team.derelict ? "Unclaimed" : Strings.capitalize(team.name), percentString));
103102
});
104103

105104
Call.setHudText(builder.toString());
106105
}
107106

108107
// Rendering for editors
109108
editors.each(p -> {
110-
if(Vars.state.isGame()){
109+
if(Vars.state.isPlaying()){
111110
getCurrentMap().drawZoneCenters(p.con());
112111
if(!isActive()) getCurrentMap().drawZoneCircles(p.con());
113112
}
@@ -196,8 +195,8 @@ public static void resetGameCountdown(){
196195

197196
public static void triggerShowdown(List<Team> teams){
198197
showdown = true;
199-
Call.sendMessage("[red]SHOWDOWN[].");
200198
resetGameCountdown();
199+
Call.warningToast((char)9888, "[red]SHOWDOWN ![]");
201200

202201
for(TeamData data : Vars.state.teams.getActive()){
203202
if(!teams.contains(data.team)){
@@ -249,6 +248,6 @@ public static long getRemainingTime(){
249248
}
250249

251250
public static boolean isActive(){
252-
return Vars.state.rules.pvp && !Vars.state.isMenu() && !Vars.state.gameOver;
251+
return Vars.state.rules.pvp && Vars.state.isPlaying() && !Vars.state.gameOver;
253252
}
254253
}

0 commit comments

Comments
 (0)