awacke1 commited on
Commit
e2a4174
·
verified ·
1 Parent(s): 8bbca49

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import random
4
+ from PIL import Image
5
+
6
+ # Set up the title and description
7
+ st.title("Dungeon Map Generator")
8
+ st.write("This app generates random dungeon maps using pre-designed templates or dynamically creates new layouts.")
9
+
10
+ # Directory for map images
11
+ map_dir = "maps" # Replace with your actual directory containing .png files
12
+
13
+ # Create layout for map generation and details
14
+ with st.container():
15
+ st.header("Dungeon Map")
16
+ col1, col2 = st.columns(2)
17
+
18
+ # Display the dungeon map
19
+ with col1:
20
+ if os.path.exists(map_dir):
21
+ # Randomly select a map image
22
+ map_files = [f for f in os.listdir(map_dir) if f.endswith(".png")]
23
+ if map_files:
24
+ selected_map = random.choice(map_files)
25
+ map_path = os.path.join(map_dir, selected_map)
26
+ st.image(Image.open(map_path), caption="Generated Dungeon Map")
27
+ else:
28
+ st.write("No map images found in the directory.")
29
+ else:
30
+ st.write("Map directory does not exist.")
31
+
32
+ # Generate Key and Outline
33
+ with col2:
34
+ st.subheader("Map Key")
35
+ st.write("""
36
+ - **V20**: Dining Hall
37
+ - **V21**: Storage Room
38
+ - **V22**: Hallway
39
+ - **V23**: Guard Room
40
+ - **V24**: Training Room
41
+ - **V25**: Treasury
42
+ - **V26**: Throne Room
43
+ - **V27**: Passageway
44
+ - **V28**: Crypt
45
+ - **V29**: Prison
46
+ - **V30**: Exit Hall
47
+ - **V31**: Barracks
48
+ - **V32**: Workshop
49
+ - **V33**: Common Room
50
+ - **V34**: Secret Chamber
51
+ - **V35**: Armory
52
+ - **V36**: Ritual Room
53
+ """)
54
+
55
+ # Add an option to dynamically generate maps
56
+ st.subheader("Generate a New Dungeon")
57
+ if st.button("Create New Map"):
58
+ st.write("**Feature coming soon!** Dynamically generating new maps using procedural algorithms.")
59
+
60
+ # Sidebar for user options
61
+ st.sidebar.title("Options")
62
+ st.sidebar.write("Select map options or upload your own dungeon map template:")
63
+ uploaded_file = st.sidebar.file_uploader("Upload a .png map file", type="png")
64
+
65
+ if uploaded_file:
66
+ with open(os.path.join(map_dir, uploaded_file.name), "wb") as f:
67
+ f.write(uploaded_file.getbuffer())
68
+ st.sidebar.success("File uploaded successfully!")