Initial Commit for some cardstuffs
This commit is contained in:
@@ -4,11 +4,11 @@ from PIL import Image
|
|||||||
import random
|
import random
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
IMAGE_LENGTH = 32
|
IMAGE_LENGTH = 16
|
||||||
NUM_COLOURS = 3
|
NUM_COLOURS = 3
|
||||||
|
|
||||||
def generate_array(colours):
|
def generate_array(colours):
|
||||||
array = [[9]*IMAGE_LENGTH for _ in range(IMAGE_LENGTH+1)]
|
array = [[(0, 0, 0)]*IMAGE_LENGTH for _ in range(IMAGE_LENGTH+1)]
|
||||||
for i in range(IMAGE_LENGTH):
|
for i in range(IMAGE_LENGTH):
|
||||||
for j in range(IMAGE_LENGTH):
|
for j in range(IMAGE_LENGTH):
|
||||||
array[j][i] = random.choice(colours)
|
array[j][i] = random.choice(colours)
|
||||||
|
|||||||
15
card_stuffs/.gitignore
vendored
Normal file
15
card_stuffs/.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
debug/
|
||||||
|
target/
|
||||||
|
test_files/all-cards.json
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
|
*.pdb
|
||||||
7
card_stuffs/Cargo.lock
generated
Normal file
7
card_stuffs/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "card_stuffs"
|
||||||
|
version = "0.1.0"
|
||||||
6
card_stuffs/Cargo.toml
Normal file
6
card_stuffs/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "card_stuffs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
64
card_stuffs/src/lib.rs
Normal file
64
card_stuffs/src/lib.rs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
pub enum Suit {
|
||||||
|
Heart,
|
||||||
|
Diamond,
|
||||||
|
Club,
|
||||||
|
Spade
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum Value {
|
||||||
|
Ace,
|
||||||
|
Two,
|
||||||
|
Three,
|
||||||
|
Four,
|
||||||
|
Five,
|
||||||
|
Six,
|
||||||
|
Seven,
|
||||||
|
Eight,
|
||||||
|
Nine,
|
||||||
|
Ten,
|
||||||
|
Jack,
|
||||||
|
Queen,
|
||||||
|
King
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Value {
|
||||||
|
pub fn indexed_values(&self) -> u8 {
|
||||||
|
match *self {
|
||||||
|
Value::Ace => 1,
|
||||||
|
Value::Two => 2,
|
||||||
|
Value::Three => 3,
|
||||||
|
Value::Four => 4,
|
||||||
|
Value::Five => 5,
|
||||||
|
Value::Six => 6,
|
||||||
|
Value::Seven => 7,
|
||||||
|
Value::Eight => 8,
|
||||||
|
Value::Nine => 9,
|
||||||
|
Value::Ten => 10,
|
||||||
|
Value::Jack => 11,
|
||||||
|
Value::Queen => 12,
|
||||||
|
Value::King => 13,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Card {
|
||||||
|
pub suit: Suit,
|
||||||
|
pub value: Value,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user