Skip to content

Commit

Permalink
feat: Add Concierge Mii actions
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jun 29, 2024
1 parent 62e8366 commit ff0674b
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 8 deletions.
151 changes: 151 additions & 0 deletions migrations/versions/81cfa0d8b36c_add_conciergemiiactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
"""Add ConciergeMiiActions
Revision ID: 81cfa0d8b36c
Revises: 357b58eaf27b
Create Date: 2024-06-29 17:47:17.413325
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "81cfa0d8b36c"
down_revision = "357b58eaf27b"
branch_labels = None
depends_on = None


def upgrade():
# We need some workarounds to cast the integer value to the enum.
# First drop the null constraint.
op.alter_column(
"concierge_miis", "action", existing_type=sa.INTEGER(), nullable=True
)

# Set everything to null
op.execute(
"""
UPDATE concierge_miis
SET action = NULL;
"""
)

# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("concierge_miis", schema=None) as batch_op:
batch_op.alter_column(
"action",
existing_type=sa.INTEGER(),
type_=sa.Enum(
"NormalMaleA",
"NormalFemaleS",
"NormalMaleS",
"NormalFemaleS2",
"NormalMaleS2",
"CheerfulMaleA",
"CheerfulFemaleS",
"CheerfulMaleS",
"SaluteMaleA",
"SaluteFemaleS",
"SaluteMaleS",
"ForeignerA",
"ForeignerS",
"CelebrityA",
"CelebrityS",
"CelebrationA",
"CelebrationS",
"AmazingA",
"AmazingS",
"GreetingS",
"ApologyS",
"Zundoko",
"Takeshi",
name="conciergemiiactions",
),
existing_nullable=False,
postgresql_using="action::text::conciergemiiactions",
)

# ### end Alembic commands ###

# Now set all columns to the default (NormalMaleA)
op.execute(
"""
UPDATE concierge_miis
SET action = 'NormalMaleA';
"""
)

# Finally re-add the constraint.
op.alter_column(
"concierge_miis",
"action",
existing_type=sa.Enum(name="conciergemiiactions"),
nullable=False,
)


def downgrade():
# Just reverse the upgrade
op.alter_column(
"concierge_miis",
"action",
existing_type=sa.Enum(name="conciergemiiactions"),
nullable=True,
)

# Set everything to null
op.execute(
"""
UPDATE concierge_miis
SET action = NULL;
"""
)

# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("concierge_miis", schema=None) as batch_op:
batch_op.alter_column(
"action",
existing_type=sa.Enum(
"NormalMaleA",
"NormalFemaleS",
"NormalMaleS",
"NormalFemaleS2",
"NormalMaleS2",
"CheerfulMaleA",
"CheerfulFemaleS",
"CheerfulMaleS",
"SaluteMaleA",
"SaluteFemaleS",
"SaluteMaleS",
"ForeignerA",
"ForeignerS",
"CelebrityA",
"CelebrityS",
"CelebrationA",
"CelebrationS",
"AmazingA",
"AmazingS",
"GreetingS",
"ApologyS",
"Zundoko",
"Takeshi",
name="conciergemiiactions",
),
type_=sa.INTEGER(),
existing_nullable=False,
)

# ### end Alembic commands ###

op.execute(
"""
UPDATE concierge_miis
SET action = 1;
"""
)

op.alter_column(
"concierge_miis", "action", existing_type=sa.INTEGER(), nullable=False
)
39 changes: 38 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,49 @@ class PayPosters(db.Model):
aspect = db.Column(db.Boolean, nullable=False)


class ConciergeMiiActions(enum.Enum):
NormalMaleA = 1
NormalFemaleS = 2
NormalMaleS = 3
NormalFemaleS2 = 4
NormalMaleS2 = 5
CheerfulMaleA = 6
CheerfulFemaleS = 7
CheerfulMaleS = 8
SaluteMaleA = 9
SaluteFemaleS = 10
SaluteMaleS = 11
ForeignerA = 12
ForeignerS = 13
CelebrityA = 14
CelebrityS = 15
CelebrationA = 16
CelebrationS = 17
AmazingA = 18
AmazingS = 19
GreetingS = 20
ApologyS = 21
Zundoko = 24
Takeshi = 25

@classmethod
def choices(cls):
return [(choice, choice.name) for choice in cls]

@classmethod
def coerce(cls, item):
return cls(int(item)) if not isinstance(item, cls) else item

def __str__(self):
return str(self.value)


class ConciergeMiis(db.Model):
mii_id = db.Column(
db.Integer, db.ForeignKey("mii_data.mii_id"), primary_key=True, unique=True
)
clothes = db.Column(db.Integer, nullable=False)
action = db.Column(db.Integer, nullable=False)
action = db.Column(db.Enum(ConciergeMiiActions), nullable=False)
prof = db.Column(db.String(129), nullable=False)
movie_id = db.Column(db.Integer, nullable=False)
voice = db.Column(db.Boolean, default=False, nullable=False)
Expand Down
9 changes: 9 additions & 0 deletions templates/concierge_action.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
{% block content %}
<form action="" method="post" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ form.action.label(class_="label") }}
<div class="control has-icons-left block">
<div class="select">{{ form.action }}
</div>
<div class="icon is-small is-left">
<i class="fa-solid fa-circle-exclamation"></i>
</div>
</div>

<p>{{ form.prof.label(class_="label") }}</p>
{{ form.prof(class_="textarea") }}
<p>{{ form.message1.label(class_="label") }}</p>
Expand Down
6 changes: 4 additions & 2 deletions theunderground/concierge.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def add_concierge(mii_id):
concierge_data = ConciergeMiis(
mii_id=mii_id,
clothes=1, # TODO: Allow disabling of custom clothes
action=1, # TODO: Allow changing of whatever the heck "action" is
prof=form.prof.data, # TODO: Add this.
action=form.action.data,
prof=form.prof.data,
movie_id=form.movieid.data,
voice=False, # The web console does not currently support this
)
Expand Down Expand Up @@ -85,6 +85,7 @@ def edit_concierge(mii_id):
mii_msg_infos = retrieved_data

if form.validate_on_submit():
mii_msg_infos[0][0].action = form.action.data
mii_msg_infos[0][0].prof = form.prof.data
mii_msg_infos[0][0].movie_id = form.movieid.data

Expand All @@ -97,6 +98,7 @@ def edit_concierge(mii_id):
return redirect(url_for("list_concierge"))
else:
# Populate the data
form.action.data = mii_msg_infos[0][0].action
form.prof.data = mii_msg_infos[0][0].prof
form.movieid.data = mii_msg_infos[0][0].movie_id
for _, info in mii_msg_infos:
Expand Down
19 changes: 15 additions & 4 deletions theunderground/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
from wtforms import (
StringField,
SubmitField,
PasswordField,
FileField,
SelectField,
TextAreaField,
BooleanField,
IntegerField,
)
from wtforms.validators import DataRequired, Length, ValidationError

from models import RoomBGMTypes, RoomContentBGMTypes, ContentTypes, LinkTypes
from wtforms.validators import DataRequired, Length

from models import (
RoomBGMTypes,
RoomContentBGMTypes,
ContentTypes,
LinkTypes,
ConciergeMiiActions,
)

"""
Reference:
Expand Down Expand Up @@ -165,6 +170,12 @@ class DeleteForm(FlaskForm):


class ConciergeForm(FlaskForm):
action = SelectField(
"Mii Action",
choices=ConciergeMiiActions.choices(),
coerce=ConciergeMiiActions.coerce,
)

prof = TextAreaField("Profession", validators=[DataRequired(), Length(max=129)])
message1 = TextAreaField("Message 1", validators=[DataRequired()])
message2 = TextAreaField("Message 2", validators=[DataRequired()])
Expand Down
2 changes: 1 addition & 1 deletion url1/mii.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def mii_met(mii_id):
"clothes": concierge_mii.clothes,
"color1": mii_metadata.color1,
"color2": mii_metadata.color2,
"action": concierge_mii.action,
"action": concierge_mii.action.value,
"prof": concierge_mii.prof,
"name": mii_metadata.name,
"msginfo": msginfo,
Expand Down

0 comments on commit ff0674b

Please sign in to comment.