Skip to content

Commit

Permalink
Fix health calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mstelz committed Nov 30, 2024
1 parent 640502a commit a965d7a
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 37 deletions.
63 changes: 33 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Easily and automatically create **Victory at Sea** ship cards for your 3D-printed or custom ships! This project mimics the style, size, and information layout of the official cards provided by **Warlord Games** while allowing you to customize ships you’ve printed yourself.

![Project Demo Screenshot](./output_images/New_Mexico.png) <!-- Replace with an actual screenshot -->

![Project Demo Screenshot](./output_images/New_Mexico_Class_Battleship.png)
---

## Features
Expand Down Expand Up @@ -68,19 +67,18 @@ project_root/

Defines the basic information about each ship.


| Field | Description | Example |
|----------------|----------------------------------------------------|---------------------------|
| `ship_id` | Unique ID for the ship | `1` |
| `ship_name` | Name of the ship | `New Mexico` |
| `ship_type` | Type of the ship | `Battleship` |
| `points` | Point cost | `395` |
| `flank_speed` | Flank speed in inches | `4"` |
| `armour` | Ship's armor rating | `6+` |
| `hull` | Ship's hull value (current/max) | `72/24` |
| `traits` | Special traits | `Aircraft 4, Armoured Deck, Torpedo Belt 2` |
| `ship_image` | Path to the ship image relative to the ship_images folder | `new_mexico.png` |
| `nation` | Path to the nation's image relative to the flags folder | `usa.png`
| Field | Description | Example |
| ------------- | --------------------------------------------------------- | ------------------------------------------- |
| `ship_id` | Unique ID for the ship | `1` |
| `ship_name` | Name of the ship | `New Mexico` |
| `ship_type` | Type of the ship | `Battleship` |
| `points` | Point cost | `395` |
| `flank_speed` | Flank speed in inches | `4"` |
| `armour` | Ship's armor rating | `6+` |
| `hull` | Ship's hull value (current/max) | `72/24` |
| `traits` | Special traits | `Aircraft 4, Armoured Deck, Torpedo Belt 2` |
| `ship_image` | Path to the ship image relative to the ship_images folder | `new_mexico.png` |
| `nation` | Path to the nation's image relative to the flags folder | `usa.png` |

#### Example

Expand All @@ -94,29 +92,31 @@ ship_id,ship_name,ship_type,points,flank_speed,armour,hull,traits,ship_image

Defines the weapon systems for each ship.


| Field | Description | Example |
|-----------------|--------------------------------------------------|---------------|
| `ship_id` | ID matching the ship from `ships.csv` | `1` |
| `weapon_system` | Name of the weapon system | `A Turret` |
| `fire_arc` | Firing arc of the weapon | `Fore` |
| `point_blank` | Point-blank range | `9"` |
| `short` | Short range | `18"` |
| `long` | Long range | `27"` |
| `extreme` | Extreme range | `37"` |
| `ad` | Attack dice | `3` |
| `ap` | Armor penetration | `+2` |
| `dd` | Damage dice | `3` |
| `traits` | Special traits | `-` |
| Field | Description | Example |
| --------------- | ------------------------------------- | ---------- |
| `ship_id` | ID matching the ship from `ships.csv` | `1` |
| `weapon_system` | Name of the weapon system | `A Turret` |
| `fire_arc` | Firing arc of the weapon | `Fore` |
| `point_blank` | Point-blank range | `9"` |
| `short` | Short range | `18"` |
| `long` | Long range | `27"` |
| `extreme` | Extreme range | `37"` |
| `ad` | Attack dice | `3` |
| `ap` | Armor penetration | `+2` |
| `dd` | Damage dice | `3` |
| `traits` | Special traits | `-` |

#### Fire Arcs

##### Valid Fire Arcs

Fire arcs are case-insensitive and support the following single or combined arcs:

- Single arcs: `Fore`, `Aft`, `Port`, `Starboard`
- Combined arcs are seperated by a comma: `Fore, Aft`

##### Fire Arc Images

Fire arc images are generated using the `createArc.py` script. These images will be stored in the fire_arcs/ folder and linked dynamically on the ship cards.

#### Example
Expand Down Expand Up @@ -146,6 +146,7 @@ python generate.py
### Running via Executable

1. Ensure you have the following files and folders in the same directory as the executable:

- `ships.csv`: Contains ship data.
- `weapon_systems.csv`: Contains weapon data.
- `ship_images/`: Directory for ship images.
Expand All @@ -154,11 +155,13 @@ python generate.py
2. Place the executable in the root directory of your setup.

3. Run the executable:

- On Windows:
```cmd
VictoryAtSeaCardGenerator.exe
```
- On Linux/Mac:
```bash
./VictoryAtSeaCardGenerator
```
Expand All @@ -178,7 +181,7 @@ Generated cards will be saved in the `output_images/` folder.
### Donate
To help me with creating new awesome tools and models you can
To help me with creating new awesome tools and models you can
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/mstelz)
Expand Down
Binary file modified VASCardGenerator.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions createExecutable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyinstaller --onefile --name VASCardGenerator --add-data "fonts:fonts" --add-data "shipcard.html:." generate.py
mv ./dist/VASCardGenerator.exe .
rm -rf dist
rm -rf build
2 changes: 1 addition & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def draw_vertical_lines(image_path, num_top_lines):
driver.save_screenshot(screenshot_path)

# Add vertical lines after ensuring the image has been saved at 300 DPI
draw_vertical_lines(screenshot_path, int(str(ship["hull"]).split("/")[0][0]))
draw_vertical_lines(screenshot_path, int(str(ship["hull"]).split("/")[0]) // 10)

# Clean up the temporary HTML file
os.remove(temp_html_path)
Expand Down
Binary file added output_images/6-Gun_Armed_Merchant_Cruiser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed output_images/Essex.png
Binary file not shown.
Binary file added output_images/Essex_Class_Carrier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed output_images/John_C._Butler.png
Binary file not shown.
Binary file added output_images/John_C._Butler_Class_Destroyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed output_images/Kagero.png
Binary file not shown.
Binary file added output_images/Kagero_Class_Destroyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Liner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed output_images/New_Mexico.png
Binary file not shown.
Binary file added output_images/New_Mexico_Class_Battleship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Oil_Tanker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Seaplane_Tender.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Tramp_Freighter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Troop_Ship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_images/Victory_Class_Cargo_Ship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion shipcard.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<div class="header">
<div class="title">
${nation_html} <!-- Dynamically insert the nation flag image -->
<h1>${ship_name} CLASS ${ship_type}</h1>
<h1>${ship_name}</h1>
</div>

${ship_image_html} <!-- Dynamically insert the ship image -->
Expand Down
15 changes: 11 additions & 4 deletions ships.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
ship_id,ship_name,ship_type,points,flank_speed,armour,hull,traits,ship_image,nation
1,Essex,Carrier,270,"6""",3+,70/23,"Advanced Radar, Carrier, Torpedo Belt 3",essex.png,usa.png
2,New Mexico,Battleship,395,"4""",6+,72/24,"Aircraft 4, Armoured Deck, Torpedo Belt 2",new_mexico.png,usa.png
3,John C. Butler,Destroyer,60,"5""",1+,4/1,"Agile, Advanced Radar, Sub-Hunter, Depth Charge, Hedgehogs",john-c-butler.png,usa.png
4,Kagero,Destroyer,100,"7""",1+,5/2,"Agile, Depth Charge",kagero-class.png,japan.png
1,Essex Class Carrier,Carrier,270,"6""",3+,70/23,"Advanced Radar, Carrier, Torpedo Belt 3",essex.png,usa.png
2,New Mexico Class Battleship,Battleship,395,"4""",6+,72/24,"Aircraft 4, Armoured Deck, Torpedo Belt 2",new_mexico.png,usa.png
3,John C. Butler Class Destroyer,Destroyer,60,"5""",1+,4/1,"Agile, Advanced Radar, Sub-Hunter, Depth Charge, Hedgehogs",john-c-butler.png,usa.png
4,Kagero Class Destroyer,Destroyer,100,"7""",1+,5/2,"Agile, Depth Charge",kagero-class.png,japan.png
5,6-Gun Armed Merchant Cruiser,Civilian,25,"3""",1+,15/5,Lumbering,,
6,Liner,Civilian,25,"6""",1+,72/24,Lumbering,,
7,Oil Tanker,Civilian,30,"4""",1+,15/5,Lumbering,,
8,Seaplane Tender,Civilian,25,"4""",1+,12/4,"Aircraft 6, Lumbering",,
9,Tramp Freighter,Civilian,10,"2""",1+,6/2,,,
10,Troop Ship,Civilian,25,"3""",1+,16/5,Lumbering,,
11,Victory Class Cargo Ship,Civilian,30,"3""",1+,14/4,Lumbering,,
17 changes: 16 additions & 1 deletion weapon_systems.csv
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,19 @@ ship_id,weapon_system,fire_arc,point_blank,short,long,extreme,ad,ap,dd,traits
4,Light Guns (6 x 5-inch),"Fore, Aft, Port, Starboard","5""","10""","15""","20""",3,2,1,Weak
4,AA Battery,"Fore, Aft, Port, Starboard",-,-,-,-,-,-,-,Local 1
4,Port/Starboard Type 93 Torpedoes,"Port, Starboard","8""","17""","25""","34""",4,-,3,"Devastating, Slow-Loading, Wakeless"
4,Port/Starboard Type 93 Torpedoes,"Port, Starboard","8""","17""","25""","34""",4,-,3,"Devastating, Slow-Loading, Wakeless"
4,Port/Starboard Type 93 Torpedoes,"Port, Starboard","8""","17""","25""","34""",4,-,3,"Devastating, Slow-Loading, Wakeless"
5,Light Guns (6 x 6-inch),"Fore, Aft, Port, Starboard","4""","9""","13""","18""",4,-2,1,"Restricted, Weak"
5,AA Battery,"Fore, Aft, Port, Starboard","1""","2""","3""","5""",1,-,-,Local 1
5,Port Torpedoes,Port,"2""","5""","7""","10""",2,-,3,Devastating
5,Starboard Torpedeos,Starboard,"2""","5""","7""","10""",2,-,3,Devastating
6,Light Guns (1 x 4-inch),"Aft, Port, Starboard","3""","6""","9""","12""",1,-2,1,"Slow-Loading, Weak"
6,AA Battery,"Fore, Aft, Port, Starboard",-,-,-,-,-,-,-,Local 1
7,Light Guns (1 x 5-inch),"Aft, Port, Startboard","4""","8""","12""","16""",1,-2,1,"Slow-Loading, Weak"
7,AA Battery,"Fore, Aft, Port, Starboard",-,-,-,-,-,-,-,Local 1
8,Light Guns (4 x 4.7-inch),"Fore, Aft, Port, Starboard","4""","8""","12""","16""",2,-2,1,"Restricted, Weak"
8,AA Battery,"Fore, Aft, Port, Starboard",-,-,-,-,-,-,-,Local 1
9,Light Guns (1 x 4-inch),"Aft, Port, Starboard","3""","6""","9""","12""",1,-2,1,"Slow-Loading, Weak"
10,Light Guns (1 x 4-inch),"Aft, Port, Starboard","3""","6""","9""","12""",1,-2,1,"Slow-Loading, Weak"
10,AA Battery,"Fore, Aft, Port, Starboard",-,-,-,-,-,-,-,Local 1
11,Light Guns (1 x 5-inch),"Aft, Port, Starboard","4""","9""","13""","18""",1,-2,1,"DP, Slow-Loading, Weak"
11,AA Battery,"Fore, Aft, Port, Starboard","1""","3""","4""","6""",1,-,-,Local 1

0 comments on commit a965d7a

Please sign in to comment.