Hi,
hiermit stelle ich euch das Spiel
WordMix zur Verfügung.
Ihr könnt natürlich alles so ändern, wie ihr wollt.
Legt erstmal diese beiden Klassen an:
WordMix.java (bei knuddels.game)
WordMixUtility.java (bei tools)
WordMix.java:
http://pastebin.com/PPXvvQGU
WordMixUtility.java:
http://pastebin.com/thad01Xf
Nachdem ihr dies getan habt, geht ihr zu
Channel.java.
Sucht:
|
Java-Quelltext
|
1
2
3
|
} else if (gameName.equals("MAFIA")) {
game = new Mafia(this);
}
|
Darunter:
|
Java-Quelltext
|
1
2
3
|
else if (gameName.equals("WORDMIX")) {
game = new WordMix(this);
}
|
Nun kommen wir zum
Log. Öffnet
PacketCreator.java und sucht diese Methode:
addChannelStyle(PacketBuilder buffer, ChannelStyle style)
Fügt einen neuen Parameter hinzu:
|
Java-Quelltext
|
1
|
addChannelStyle(PacketBuilder buffer, ChannelStyle style, boolean doNotLogJames)
|
Sucht:
|
Java-Quelltext
|
1
2
|
buffer.writeString(style.getBackground()); // user list
buffer.writeByte(0x00);
|
Löscht das, was darunter ist und fügt folgendes ein:
|
Java-Quelltext
|
1
2
3
|
buffer.writeString((doNotLogJames ? "F" : "T"));
buffer.writeByte(0x00);
buffer.writeString("-");
|
Überall, wo die Methode addChannelStyle aufgerufen wird, ist der Paramater (boolean):
|
Java-Quelltext
|
1
|
channel.getName().startsWith("WordMix")
|
Example:
|
Java-Quelltext
|
1
|
addChannelStyle(buffer, channel.getStyle(), channel.getName().startsWith("WordMix"));
|
Danach öffnet ihr
Client.java und fügt als globale Variable dies ein:
|
Java-Quelltext
|
1
|
private float wordmixPoints;
|
Suche die Methode
increaseKisses, füge darüber ein:
|
Java-Quelltext
|
1
2
3
4
5
6
7
|
public void increaseWordMixPoints(float wordmixPoints) {
this.wordmixPoints += wordmixPoints;
}
public float getWordMixPoints() {
return wordmixPoints;
}
|
Suche dann die Methode
loadStats:
|
Java-Quelltext
|
1
|
wordmixPoints = rs.getFloat("wordmixpoints");
|
WICHTIG: saveStats() müsst ihr SELBER bearbeiten, da es sein kann, dass ihr noch andere Sachen im Profil habt (z.B. Fifty! Punkte, etc.)
Kommen wir zu CommandParser.java:
Suche:
|
Java-Quelltext
|
1
|
private static NumberFormat nf;
|
Füge darunter ein:
|
Java-Quelltext
|
1
|
private static DecimalFormat df;
|
Suche:
|
Java-Quelltext
|
1
|
nf = NumberFormat.getInstance(Locale.GERMANY);
|
Füge darunter ein:
|
Java-Quelltext
|
1
|
df = new DecimalFormat("0.00");
|
Nun geht ihr dahin, wo das Profil angezeigt wird (whois.append(...)) und fügt hinzu:
|
Java-Quelltext
|
1
2
3
|
if (target.getWordMixPoints() >= 100) {
whois.append(String.format("°>gt.gif<° _°R°%s°r°_ WordMix Punkte#", nf.format((int)target.getWordMixPoints())));
}
|
Ein neuer Command:
|
Java-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
} else if (cmd.equals("wordmix")) {
Object[] data = WordMixUtility.Read();
if (data != (Object[])null) {
String nickname = String.format("°20B>_h%s|/serverpp "|/w "<r°", data[0]);
float nPoints = Float.parseFloat(data[1].toString());
String nSentence = data[2].toString();
float nSeconds = Float.parseFloat(data[3].toString());
String showString = String.format("°28°_WordMix Bestleistung des Tages:_°15°###_%s_ °15° erreichte _°20°%s Punkte°r°_°15° mit folgendem Satz:##°20°_""%s_""°15°##(in _%s_ Sekunden)##", nickname, df.format(nPoints), nSentence, df.format(nSeconds));
if (nPoints > 0.00f) {
client.send(Popup.create("Bestleistung bei WordMix", "Bestleistung bei WordMix", showString, 640, 475));
} else {
client.send(Popup.create("Bestleistung bei WordMix", "Bestleistung bei WordMix", "Bisher hat niemand den Tagesrekord aufgestellt.", 640, 475));
}
} else {
client.send(Popup.create("Bestleistung bei WordMix", "Bestleistung bei WordMix", "Bisher hat niemand den Tagesrekord aufgestellt.", 640, 475));
}
}
|
Öffne schließlich
Server.java:
Suche:
|
Java-Quelltext
|
1
|
System.out.println(String.format("Listening on port %s", port));
|
Füge darunter ein:
|
Java-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
Thread thread = new Thread(new Runnable() {
public void run() {
while (true) {
String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
if (time.equals("00:00:00")) {
WordMixUtility.Reset();
}
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
}
});
thread.start();
|
Jetzt
MySQL, folgende Befehle:
|
MySQL-Abfrage(n)
|
1
2
3
4
5
6
7
8
9
|
CREATE TABLE `wordmix` ( SENTENCE text NOT NULL );
ALTER TABLE `accounts` ADD `wordmixpoints` FLOAT(10,2) UNSIGNED
CREATE TABLE `wordmixrekord` (
nick varchar(25) NOT NULL,
points FLOAT(4,2) UNSIGNED,
sentence TEXT NOT NULL,
seconds FLOAT(4,2) UNSIGNED
);
|
Neuer Eintrag bei
wordmixrekord:
|
MySQL-Abfrage(n)
|
1
|
INSERT INTO `wordmixrekord` SET `nick` = '', `points` = '0.00', `sentence` = '', `seconds` = '0.0'
|
Legt nun einen neuen Channel an:
- (bedeutet, ihr müsst es anpassen!)
ID: -
Name: WordMix
Size: 15
Topic: Hier kann mit James WordMix gespielt werden. Einfach °BB>/h wordmix|"<r° für Infos zum Spiel eingeben.
BackgroundImage: pics/wordmix.jpg (nicht vergessen, das Hintergrundbild auch hinzuzufügen im pics-Ordner!)
BackgroundPosition: 6
Style: -
Game: WORDMIX
Neuer Channelstyle:
ID: -
Fontsize: 16
Linespace: 10
Foreground: 0,0,0
Background: 192,192,192
Red: R
Blue: B
Administrator: 255,0,0
Moderator: 0,0,140
Das war's dann. Falls ich irgendwas vergessen haben sollte, bitte melden.
Wenn dann noch Fragen bestehen, könnt ihr mich gerne fragen.
MfG