-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathWinEvent.java
More file actions
98 lines (82 loc) · 2.19 KB
/
Copy pathWinEvent.java
File metadata and controls
98 lines (82 loc) · 2.19 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
/*
* Copyright (c) 2001-2025 Mathew A. Nelson and Robocode contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://robocode.sourceforge.io/license/epl-v10.html
*/
package robocode;
import net.sf.robocode.peer.IRobotStatics;
import net.sf.robocode.serialization.ISerializableHelper;
import net.sf.robocode.serialization.RbSerializer;
import robocode.robotinterfaces.IBasicEvents;
import robocode.robotinterfaces.IBasicRobot;
import java.awt.*;
import java.nio.ByteBuffer;
/**
* This event is sent to {@link Robot#onWin(WinEvent) onWin()} when your robot
* wins the round in a battle.
*
* @author Mathew A. Nelson (original)
* @author Flemming N. Larsen (contributor)
*/
public final class WinEvent extends Event {
private static final long serialVersionUID = 1L;
private final static int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!
/**
* Called by the game to create a new WinEvent.
*/
public WinEvent() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public int getPriority() {
return DEFAULT_PRIORITY;
}
/**
* {@inheritDoc}
*/
@Override
int getDefaultPriority() {
return DEFAULT_PRIORITY;
}
/**
* {@inheritDoc}
*/
@Override
void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) {
IBasicEvents listener = robot.getBasicEventListener();
if (listener != null) {
listener.onWin(this);
}
}
/**
* {@inheritDoc}
*/
@Override
boolean isCriticalEvent() {
return true;
}
/**
* {@inheritDoc}
*/
@Override
byte getSerializationType() {
return RbSerializer.WinEvent_TYPE;
}
static ISerializableHelper createHiddenSerializer() {
return new SerializableHelper();
}
private static class SerializableHelper implements ISerializableHelper {
public int sizeOf(RbSerializer serializer, Object object) {
return RbSerializer.SIZEOF_TYPEINFO;
}
public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {}
public Object deserialize(RbSerializer serializer, ByteBuffer buffer) {
return new WinEvent();
}
}
}