mirror of
https://github.com/darksaid98/EntityBingo.git
synced 2026-12-01 15:58:46 +00:00
Base framework
This commit is contained in:
1 parent
d97d25e7c6
commit
c54512bfb6
7 files changed
+110
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package org.aubrithehuman.entitybingo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class BingoEvent {
|
||||
|
||||
private final HashMap<String, Integer> entries;
|
||||
|
||||
|
||||
public BingoEvent() {
|
||||
this.entries = new HashMap<>();
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if player has not yet made a guess, else return false
|
||||
*
|
||||
* @param player player
|
||||
* @param value value
|
||||
* @return previous guess
|
||||
*/
|
||||
public boolean addEntry(String player, int value) {
|
||||
if(entries.containsKey(player)) {
|
||||
entries.put(player, value);
|
||||
return true;
|
||||
} else {
|
||||
entries.put(player, value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int totalGuesses() {
|
||||
return this.entries.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a player based on the entry, if none match then return null;
|
||||
*
|
||||
* @param i value
|
||||
* @return player
|
||||
*/
|
||||
public String getByEntry(int i) {
|
||||
for(String s : entries.keySet()) {
|
||||
if (entries.get(s) == i) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user