Project: We will implement a simplified game of Scrimish, a strategy card game,
ID: 3571619 • Letter: P
Question
Project: We will implement a simplified game of Scrimish, a strategy card game, with 2 players: a human (i.e., the user) and the computer. Scrimish is a card game that was funded using kickstarter.com with the objective that luck is not a component of the game.
Both players have a set of cards composed of the following cards and numbers:
#1 Dagger Cards (x5 per player)
#2 Sword Cards (x5 per player)
#3 Morning Star Cards (x3 per player)
#4 War Axe Cards (x3 per player)
#5 Halberd Cards (x2 per player)
#6 Longsword Cards (x2 per player)
'A' Archer Cards (x2 per player)
'S' Shield Cards (x2 per player)
Crown Card (x1 per player)
Setup: The user player places 5 Piles of 5 Cards each face down in front of him. The Crown Card should be hidden on the bottom of one of the 5 Piles. The rest of the Cards may be arranged however you like. The computer does the same thing: the crown card is placed on the bottom of a random pile, while the rest of the card are distributed into 5 piles (such that we have 5 cards in each pile).
#1 Dagger Cards (x5 per player)
#2 Sword Cards (x5 per player)
#3 Morning Star Cards (x3 per player)
#4 War Axe Cards (x3 per player)
#5 Halberd Cards (x2 per player)
#6 Longsword Cards (x2 per player)
'A' Archer Cards (x2 per player)
'S' Shield Cards (x2 per player)
Crown Card (x1 per player)
Setup: The user player places 5 Piles of 5 Cards each face down in front of him. The Crown Card should be hidden on the bottom of one of the 5 Piles. The rest of the Cards may be arranged however you like. The computer does the same thing: the crown card is placed on the bottom of a random pile, while the rest of the card are distributed into 5 piles (such that we have 5 cards in each pile).
- Archer Card: If you attack with an Archer Card, it always wins. If your Archer Card is attacked, it always loses.
- Shield Card: Shield Cards cannot be used to attack. If your Shield Card is attacked, both your Shield Card and your opponent's attacking Card are discarded (except for Archer Cards: If a Shield Card is attacked by an Archer Card, neither Card is discarded, and both are returned face down to their original Piles). If the Shield Card is used to attack, then it looses.
- Crown Card: You can attack with your Crown Card. If you attack your opponent's Crown Card, you win. Otherwise, you lose the game.
- Instead of attacking, you may intentionally discard one Card on your turn. You do not have to reveal that Card to your opponent. You cannot intentionally discard your Crown Card.
The number of points possible for the project are 40 points:
- game setup: let the human user select the cards in each pile = 10 points,
- play one turn started by the human user = 10 points,
- play one turn started by the computer = 10 points,
- graphical user interface = 10 points.
Explanation / Answer
import javax.crypto.Cipher;
2
import javax.crypto.KeyGenerator;
3
import javax.crypto.SecretKey;
4
import javax.xml.bind.DatatypeConverter;
5
6
/**
7
* this instance program shows however AES secret writing and cryptography is wiped out Java.
8
* Please note that secret key and encrypted text is unclear binary and therefore
9
* within the following program we tend to show it in positional representation system format of the underlying bytes.
10
* @author Jayson
11
*/
12
public category AESEncryption an understandable text for secret writing
16
* 2. Get a secret key (printed in positional representation system form). In actual use this should
17
* by encrypted and unbroken safe. identical secret is needed for cryptography.
18
* 3.
19
*/
20
public static void main(String[] args) throws Exception seven
55
Cipher aesCipher = Cipher.getInstance("AES");
56
aesCipher.init(Cipher.ENCRYPT_MODE, secKey);
57
byte[] byteCipherText = aesCipher.doFinal(plainText.getBytes());
58
come byteCipherText;
59
}
60
61
/**
62
* Decrypts encrypted computer memory unit array exploitation the key used for secret writing.
63
* @param byteCipherText
64
* @param secKey
65
* @return
66
* @throws Exception
67
*/
68
public static String decryptText(byte[] byteCipherText, SecretKey secKey) throws Exception seven
70
Cipher aesCipher = Cipher.getInstance("AES");
71
aesCipher.init(Cipher.DECRYPT_MODE, secKey);
72
byte[] bytePlainText = aesCipher.doFinal(byteCipherText);
73
come new String(bytePlainText);
74
}
75
76
/**
77
* Convert a binary computer memory unit array into clear hex type
78
* @param hash
79
* @return
80
*/
81
non-public static String bytesToHex(byte[] hash) {
82
come DatatypeConverter.printHexBinary(hash);
83
}
84
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.