Skip to content

Commit 963d53f

Browse files
author
DiamondCoder
committed
done with random I hope
1 parent 34a5453 commit 963d53f

File tree

2 files changed

+100
-5
lines changed

2 files changed

+100
-5
lines changed

readme.md

+19
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,22 @@ f95-696969_Good Game, try me_v12.31 DeveloperAndStuffMaybeNotes
5252
If it doesn't begin with f95 or man ~~or dls(soon?)~~ it will be ignored.
5353

5454
This I can use to check last downloaded version, and last time the folder has changed. Also auto update if game is still on pc.
55+
56+
## aaaaaaa
57+
58+
0 - Site
59+
1 - ID
60+
2 - Name
61+
3 - Developer
62+
4 - Played version
63+
5 - Last time play
64+
6 - Rated
65+
7 - Newest version
66+
8 - Last update
67+
9 - People rating
68+
10 - Player progress
69+
11 - Still on pc?
70+
12 - Engine
71+
13 - OS
72+
14 - Language
73+
15 - Personal notes

src/main/application/randomGame.java

+81-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import java.awt.Desktop;
44

5+
import javax.swing.ButtonGroup;
56
import javax.swing.JEditorPane;
7+
import javax.swing.JLabel;
68
import javax.swing.JOptionPane;
9+
import javax.swing.JPanel;
10+
import javax.swing.JRadioButton;
711
import javax.swing.event.HyperlinkEvent;
812
import javax.swing.event.HyperlinkListener;
913

@@ -22,26 +26,98 @@ public static void fullyRandom() {
2226
}
2327

2428
public static void randomFromDeveloper() {
25-
29+
Integer devLegth = 0; String wantedRandomDev;
30+
wantedRandomDev = JOptionPane.showInputDialog(null, "Enter developer name you wish to search for:", "Random game from developer", JOptionPane.QUESTION_MESSAGE);
31+
for (int i = 0; i < allGames.length; i++) {
32+
if (allGames[i][3].equals(wantedRandomDev)) {
33+
devLegth++;
34+
}
35+
}
36+
if (devLegth == 0) { JOptionPane.showMessageDialog(null, "No games found from developer: "+wantedRandomDev, "Random game from developer", JOptionPane.INFORMATION_MESSAGE); return;}
37+
Object[][] gamesFromDevs = new Object[devLegth][allGames[0].length];
38+
for (int i = 0; i < allGames.length; i++) {
39+
if (allGames[i][3].equals(wantedRandomDev)) {
40+
gamesFromDevs[i] = allGames[i];
41+
}
42+
}
43+
Integer random = (int) (Math.random() * devLegth);
44+
Object[] result = gamesFromDevs[random];
45+
resultShow(result, "Random game from developer");
2646
}
2747

2848
public static void randomWithEngine() {
29-
49+
Integer engineLegth = 0; String wantedRandomEngine;
50+
JRadioButton engine_Flash = new JRadioButton("Flash"), engine_HTML = new JRadioButton("HTML"), engine_Java = new JRadioButton("Java"), engine_QSP = new JRadioButton("QSP"), engine_RenPy = new JRadioButton("RenPy"), engine_RPGmaker = new JRadioButton("RPGmaker"), engine_Unity = new JRadioButton("Unity"), engine_Unreal = new JRadioButton("Unreal"), engine_WinGit = new JRadioButton("WinGit"), engine_WolfRPG = new JRadioButton("WolfRPG"), engine_other = new JRadioButton("other/unknown", true);
51+
engine_Flash.setActionCommand("Flash"); engine_HTML.setActionCommand("HTML"); engine_Java.setActionCommand("Java"); engine_QSP.setActionCommand("QSP"); engine_RenPy.setActionCommand("RenPy"); engine_RPGmaker.setActionCommand("RPGmaker"); engine_Unity.setActionCommand("Unity"); engine_Unreal.setActionCommand("Unreal"); engine_WinGit.setActionCommand("WinGit"); engine_WolfRPG.setActionCommand("WolfRPG"); engine_other.setActionCommand("other/unknown");
52+
ButtonGroup engineGroup = new ButtonGroup(); engineGroup.add(engine_Flash); engineGroup.add(engine_HTML); engineGroup.add(engine_Java); engineGroup.add(engine_QSP); engineGroup.add(engine_RenPy); engineGroup.add(engine_RPGmaker); engineGroup.add(engine_Unity); engineGroup.add(engine_Unreal); engineGroup.add(engine_WinGit); engineGroup.add(engine_WolfRPG); engineGroup.add(engine_other);
53+
JLabel engineLabel = new JLabel("Select engine to search for:");
54+
JPanel enginePanel = new JPanel(); enginePanel.add(engineLabel); enginePanel.add(engine_Flash); enginePanel.add(engine_HTML); enginePanel.add(engine_Java); enginePanel.add(engine_QSP); enginePanel.add(engine_RenPy); enginePanel.add(engine_RPGmaker); enginePanel.add(engine_Unity); enginePanel.add(engine_Unreal); enginePanel.add(engine_WinGit); enginePanel.add(engine_WolfRPG); enginePanel.add(engine_other);
55+
JOptionPane.showMessageDialog(null, enginePanel, "Random game with engine", JOptionPane.QUESTION_MESSAGE);
56+
wantedRandomEngine = engineGroup.getSelection().getActionCommand();
57+
for (int i = 0; i < allGames.length; i++) {
58+
if (allGames[i][12].equals(wantedRandomEngine)) {
59+
engineLegth++;
60+
}
61+
}
62+
if (engineLegth == 0) { JOptionPane.showMessageDialog(null, "No games found with engine: "+wantedRandomEngine, "Random game with engine", JOptionPane.INFORMATION_MESSAGE); return;}
63+
Object[][] gamesWithEngine = new Object[engineLegth][allGames[0].length];
64+
for (int i = 0; i < allGames.length; i++) {
65+
if (allGames[i][12].equals(wantedRandomEngine)) {
66+
gamesWithEngine[i] = allGames[i];
67+
}
68+
}
69+
Integer random = (int) (Math.random() * engineLegth);
70+
Object[] result = gamesWithEngine[random];
71+
resultShow(result, "Random game with engine");
3072
}
3173

3274
public static void randomFromSite() {
33-
75+
Integer siteLegth = 0; String wantedRandomSite;
76+
JRadioButton site_F95 = new JRadioButton("F95zone"), site_man = new JRadioButton("Manual", true);
77+
site_F95.setActionCommand("f95"); site_man.setActionCommand("man");
78+
ButtonGroup sitesGroup = new ButtonGroup(); sitesGroup.add(site_F95); sitesGroup.add(site_man);
79+
JLabel siteLabel = new JLabel("Select site to search from:");
80+
JPanel sitePanel = new JPanel(); sitePanel.add(siteLabel) ;sitePanel.add(site_F95); sitePanel.add(site_man);
81+
JOptionPane.showMessageDialog(null, sitePanel, "Random game from site", JOptionPane.QUESTION_MESSAGE);
82+
wantedRandomSite = sitesGroup.getSelection().getActionCommand();
83+
for (int i = 0; i < allGames.length; i++) {
84+
if (allGames[i][0].equals(wantedRandomSite)) {
85+
siteLegth++;
86+
}
87+
}
88+
if (siteLegth == 0) { JOptionPane.showMessageDialog(null, "No games found from site: "+wantedRandomSite, "Random game from site", JOptionPane.INFORMATION_MESSAGE); return;}
89+
Object[][] gamesFromSite = new Object[siteLegth][allGames[0].length];
90+
for (int i = 0; i < allGames.length; i++) {
91+
if (allGames[i][0].equals(wantedRandomSite)) {
92+
gamesFromSite[i] = allGames[i];
93+
}
94+
}
95+
Integer random = (int) (Math.random() * siteLegth);
96+
Object[] result = gamesFromSite[random];
97+
resultShow(result, "Random game from site");
3498
}
3599

36100
private static void resultShow(Object[] result, String title) {
37101
Boolean[] boolSettings = folderHandle.loadSaveGamesSettings.loadSettingsFromXml.loadBooleanSettings("othersettings");
38102
String color;
39103
if (boolSettings[0]) { color = "white"; } else { color = "black"; }
104+
String finalLink;
105+
switch (result[0].toString()) {
106+
case "f95": finalLink = "<font color = 64AFFF><a href=\"https://f95zone.to/threads/"+result[1]+"/\">Update here if needed</a></font>"; break;
107+
default: finalLink = "No link available";
108+
}
40109
JEditorPane ep = new JEditorPane();
41110
ep.setContentType("text/html");
42111
// TODO language here:
43-
ep.setText("<p style=\"font-family: Arial\"><span style=\"color:"+color+"\">"+"Fully random game"+br+br+
44-
"");
112+
ep.setText("<p style=\"font-family: Arial\"><span style=\"color:"+color+"\">"+"Found a game!!!"+br+br+
113+
"From site: "+result[0]+br+
114+
"Game name: "+result[2]+br+
115+
"Developer: "+result[3]+br+
116+
"Engine: "+result[12]+br+
117+
"Is the game still on pc: " +(result[13].equals("yes")?"Yes :3":"No :/")+br+
118+
"Language(s): "+result[14]+br+
119+
"Link: " + finalLink +
120+
"</span></p>");
45121
ep.addHyperlinkListener(new HyperlinkListener() {
46122
@Override
47123
public void hyperlinkUpdate(HyperlinkEvent e) {

0 commit comments

Comments
 (0)