Skip to content

Commit

Permalink
block-based bugfix, added draw (or push), see CHANGELOG for rest
Browse files Browse the repository at this point in the history
  • Loading branch information
Parker committed Jul 21, 2011
1 parent 893e3c4 commit dc6ce32
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ v1.8:
*Players cannot place or break blocks (only if block-based is on)
*Removed some debug text
*Hitting a fence makes you leave the game

v1.9:
*Fixed bug in block-based setup
*Added draw (if you tie with the dealer no money is lost or won unless you busted or got an instant blackjack)
*The dealer's hand is now revealed to each player
*Added a configurable starting amount for non-iConomy users
Binary file modified Casino.jar
Binary file not shown.
Binary file added Casino/bin/AntiLogout.class
Binary file not shown.
Binary file modified Casino/bin/Base/Slot.class
Binary file not shown.
Binary file modified Casino/bin/Games/BlackJack/BlackJack.class
Binary file not shown.
Binary file modified Casino/bin/Main.class
Binary file not shown.
17 changes: 17 additions & 0 deletions Casino/src/AntiLogout.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;


public class AntiLogout extends PlayerListener{
Main plugin;

public AntiLogout(Main instance){
plugin = instance;
}

public void onPlayerQuit(PlayerQuitEvent event){
if(plugin.blackjack.getPlayers().contains(event.getPlayer())){
event.getPlayer().chat("leave");
}
}
}
18 changes: 11 additions & 7 deletions Casino/src/Base/Slot.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ public void write(int line, String string) {
}
}
public void bettingSigns(int num){
sign1.setLine(1,"[BET]");
sign2.setLine(0,"Current Bet:");
sign2.setLine(1, num + "");
sign1.update();
sign2.update();
if(sign1 != null && sign2 != null){
sign1.setLine(1,"[BET]");
sign2.setLine(0,"Current Bet:");
sign2.setLine(1, num + "");
sign1.update();
sign2.update();
}
}
public Sign getSign(int i) {
switch(i){
Expand All @@ -75,7 +77,9 @@ public Sign getSign(int i) {
}
}
public void concat(int line, String string) {
sign2.setLine(line, sign2.getLine(line) + string);
sign2.update();
if(line <= 3){
sign2.setLine(line, sign2.getLine(line) + string);
sign2.update();
}
}
}
22 changes: 22 additions & 0 deletions Casino/src/Games/BlackJack/BlackJack.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class BlackJack{
public HashMap<Slot, CardPlayer> slotStatus = new HashMap<Slot, CardPlayer>();
public boolean block = false;
public boolean console = true;
public ArrayList<CardPlayer> ties = new ArrayList<CardPlayer>();

/**
* Loads the locations from the config file into the game
Expand Down Expand Up @@ -123,6 +124,11 @@ public void payout(){
player.giveCash(bets.get(player)*2);
}
}
for(CardPlayer player : ties){
if(players.contains(player)){
player.giveCash(bets.get(player)*1);
}
}
}

/**
Expand Down Expand Up @@ -397,11 +403,24 @@ public void dealerTurn(){
sum = 0;
}
goal = sum;
String dealerMessage = ChatColor.YELLOW + "The dealer has ";
for(Card card : dealer.getHand()){
dealerMessage += card;
dealerMessage += ", ";
}
dealerMessage += "(" + sum + ")";

for(Player player : getPlayers()){
player.sendMessage(dealerMessage);
}
//lists all players that beat the dealer
for(CardPlayer player : finals.keySet()){
if (finals.get(player) > goal){
winners.add(player);
}
else if(finals.get(player) == goal){
ties.add(player);
}
}
}

Expand Down Expand Up @@ -575,6 +594,9 @@ public void finish(){
if(winners.contains(player)){
string += ChatColor.GREEN + "You win! (" + bets.get(player) + ")";
}
else if(ties.contains(player)){
string += ChatColor.YELLOW + "You tied! (0)";
}
//player loses
else {
string += ChatColor.RED + "You lose! (" + bets.get(player) + ")";
Expand Down
7 changes: 6 additions & 1 deletion Casino/src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,17 @@ public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, Str
//blackjack
if(cmdLabel.equalsIgnoreCase("blackjack")){
if (args.length == 2){
if(blackjack.getPlayers().size()!=0){
player.sendMessage(ChatColor.RED + "That cannot be done while a game is in progress!");
return true;
}
Sign sign = null;
Block block = player.getTargetBlock(null, 10000);
if(block.getState() instanceof Sign){
sign = (Sign) block.getState();
saveSign(sign,Integer.parseInt(args[0]),Integer.parseInt(args[1]));
blackjack.slots[Integer.parseInt(args[0])-1].setSign(Integer.parseInt(args[1]),sign);
player.sendMessage(ChatColor.YELLOW + "Sign " + args[1] + " saved properly to slot " + args[0] + "!");
return true;
}
}
Expand All @@ -287,7 +292,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, Str
addPlayer(player);
}
}
else{
else if(args.length == 1){
if(blackjack.getPlayers().size()!=0){
player.sendMessage(ChatColor.RED + "That cannot be done while a game is in progress!");
return true;
Expand Down
4 changes: 1 addition & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
TODO:
Handle logouts
Clean up the code
Add a configurable starting amount for non-iConomy users
Add the next game: Slot Machines!
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
starting amount: 100
block-based: true
slots:
'3':
Expand Down

0 comments on commit dc6ce32

Please sign in to comment.