File size: 7,111 Bytes
ff5658f
40c4791
ff5658f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40c4791
5620099
 
40c4791
 
 
 
 
 
ff5658f
c21aec9
40c4791
 
ff5658f
40c4791
 
34e2755
 
 
ff5658f
34e2755
40c4791
ff5658f
c21aec9
40c4791
c21aec9
40c4791
 
 
34e2755
 
 
ff5658f
34e2755
40c4791
ff5658f
c21aec9
 
 
ff5658f
 
 
 
 
 
c21aec9
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import os
import streamlit as st
import anthropic
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Retrieve the API key from environment variables
api_key = os.getenv("Claude_api_key")

# Initialize the Anthropic client with the API key
client = anthropic.Anthropic(api_key=api_key)

# Define the functions to generate content
def generate_game_environment(environment_description):
    message = client.messages.create(
        model="claude-3-5-sonnet-20240620",
        max_tokens=150,
        temperature=0.7,
        system="You are an expert in world-building. Generate a detailed description of a game environment based on the input.",
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": f"Create a detailed description of a game environment based on this input: {environment_description}"
                    }
                ]
            }
        ]
    )
    return message.content[0].text

def generate_protagonist(protagonist_description):
    message = client.messages.create(
        model="claude-3-5-sonnet-20240620",
        max_tokens=150,
        temperature=0.7,
        system="You are an expert in character creation. Generate a detailed description of a game protagonist based on the input.",
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": f"Create a detailed description of a game protagonist based on this input: {protagonist_description}"
                    }
                ]
            }
        ]
    )
    return message.content[0].text

def generate_antagonist(antagonist_description):
    message = client.messages.create(
        model="claude-3-5-sonnet-20240620",
        max_tokens=150,
        temperature=0.7,
        system="You are an expert in villain creation. Generate a detailed description of a game antagonist based on the input.",
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": f"Create a detailed description of a game antagonist based on this input: {antagonist_description}"
                    }
                ]
            }
        ]
    )
    return message.content[0].text

def generate_game_story(environment, protagonist, antagonist):
    story_prompt = (f"Create a detailed game story based on the following inputs:\n"
                    f"Game Environment: {environment}\n"
                    f"Protagonist: {protagonist}\n"
                    f"Antagonist: {antagonist}")
    message = client.messages.create(
        model="claude-3-5-sonnet-20240620",
        max_tokens=150,
        temperature=0.7,
        system="You are a master storyteller. Generate a detailed game story based on the inputs provided.",
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": story_prompt
                    }
                ]
            }
        ]
    )
    return message.content[0].text

# App Title
st.title("🎮 Safwan's GameMaker Studio")

# App Description
st.write("Welcome to Safwan's GameMaker Studio, a popular game development platform known for its ease of use and powerful features. Enter your ideas according to your taste and this will generate a script with a real scenario. Generate more ideas to compete with the big communities.")

# Sidebar Inputs
with st.sidebar:
    st.header("📝 Game Details")
    game_environment = st.text_input("🏞️ Game Environment", "Describe the setting of your game")
    protagonist = st.text_input("🦸‍♂️ Protagonist", "Describe the main character")
    antagonist = st.text_input("🦹‍♀️ Antagonist", "Describe the main villain or opposing force")
    if st.button("Generate Document"):
        # Generate content based on user input
        env_description = generate_game_environment(game_environment)
        protagonist_description = generate_protagonist(protagonist)
        antagonist_description = generate_antagonist(antagonist)
        game_story = generate_game_story(game_environment, protagonist, antagonist)
        
        # Store results in session state
        st.session_state.env_description = env_description
        st.session_state.protagonist_description = protagonist_description
        st.session_state.antagonist_description = antagonist_description
        st.session_state.game_story = game_story

# Layout with three columns
col1, col2, col3 = st.columns(3)

with col1:
    st.header("🌍 Game Environment")
    if 'env_description' in st.session_state:
        st.write(st.session_state.env_description)
    else:
        st.write(game_environment)
    st.markdown("---")

with col2:
    st.header("🦸‍♂️Protagonist")
    if 'protagonist_description' in st.session_state:
        st.write(st.session_state.protagonist_description)
        if st.button("Edit Protagonist Details", key="edit_protagonist"):
            new_protagonist_description = st.text_area("Edit Protagonist Description", st.session_state.protagonist_description)
            if st.button("Update Protagonist", key="update_protagonist"):
                st.session_state.protagonist_description = generate_protagonist(new_protagonist_description)
                st.experimental_rerun()
    else:
        st.write(protagonist)
    st.markdown("---")

with col3:
    st.header("🦹‍♀️ Antagonist")
    if 'antagonist_description' in st.session_state:
        st.write(st.session_state.antagonist_description)
        if st.button("Edit Antagonist Details", key="edit_antagonist"):
            new_antagonist_description = st.text_area("Edit Antagonist Description", st.session_state.antagonist_description)
            if st.button("Update Antagonist", key="update_antagonist"):
                st.session_state.antagonist_description = generate_antagonist(new_antagonist_description)
                st.experimental_rerun()
    else:
        st.write(antagonist)
    st.markdown("---")

# Combine and merge sections to generate a scenario and script
if 'env_description' in st.session_state and 'protagonist_description' in st.session_state and 'antagonist_description' in st.session_state:
    combined_content = (f"### Game Scenario\n\n"
                        f"**Environment:** {st.session_state.env_description}\n\n"
                        f"**Protagonist:** {st.session_state.protagonist_description}\n\n"
                        f"**Antagonist:** {st.session_state.antagonist_description}\n\n"
                        f"**Story:** {st.session_state.game_story}")
else:
    combined_content = "Your complete game scenario and script will be generated based on the inputs provided."

st.header("📜 Game Scenario & Script")
st.write(combined_content)