Refactor pet action management: rename PetAction to PetBasicAction, update related properties and methods, and enhance pet stats with maximum values.

This commit is contained in:
2025-02-01 23:08:25 -03:00
parent d6d3dc9f44
commit df62710b9a
14 changed files with 173 additions and 239 deletions

View File

@@ -1,116 +0,0 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using pet_companion_api.Data;
#nullable disable
namespace pet_companion_api.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250201022754_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.1");
modelBuilder.Entity("pet_companion_api.Models.Pet", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Pets");
});
modelBuilder.Entity("pet_companion_api.Models.PetStats", b =>
{
b.Property<string>("PetId")
.HasColumnType("TEXT");
b.Property<int>("Charisma")
.HasColumnType("INTEGER");
b.Property<int>("Intelligence")
.HasColumnType("INTEGER");
b.Property<int>("Strength")
.HasColumnType("INTEGER");
b.HasKey("PetId");
b.ToTable("PetStats");
});
modelBuilder.Entity("pet_companion_api.Models.Resources", b =>
{
b.Property<string>("PetId")
.HasColumnType("TEXT");
b.Property<int>("Food")
.HasColumnType("INTEGER");
b.Property<int>("Gold")
.HasColumnType("INTEGER");
b.Property<int>("Junk")
.HasColumnType("INTEGER");
b.Property<int>("Wisdom")
.HasColumnType("INTEGER");
b.HasKey("PetId");
b.ToTable("Resources");
});
modelBuilder.Entity("pet_companion_api.Models.PetStats", b =>
{
b.HasOne("pet_companion_api.Models.Pet", null)
.WithOne("Stats")
.HasForeignKey("pet_companion_api.Models.PetStats", "PetId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("pet_companion_api.Models.Resources", b =>
{
b.HasOne("pet_companion_api.Models.Pet", null)
.WithOne("Resources")
.HasForeignKey("pet_companion_api.Models.Resources", "PetId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("pet_companion_api.Models.Pet", b =>
{
b.Navigation("Resources")
.IsRequired();
b.Navigation("Stats")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,52 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace pet_companion_api.Migrations
{
/// <inheritdoc />
public partial class AddActions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "ActionSince",
table: "Pets",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<bool>(
name: "IsDead",
table: "Pets",
type: "INTEGER",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<int>(
name: "PetAction",
table: "Pets",
type: "INTEGER",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ActionSince",
table: "Pets");
migrationBuilder.DropColumn(
name: "IsDead",
table: "Pets");
migrationBuilder.DropColumn(
name: "PetAction",
table: "Pets");
}
}
}

View File

@@ -11,8 +11,8 @@ using pet_companion_api.Data;
namespace pet_companion_api.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250201025206_AddActions")]
partial class AddActions
[Migration("20250201173643_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -25,12 +25,15 @@ namespace pet_companion_api.Migrations
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<DateTime>("ActionSince")
b.Property<DateTime>("BasicActionCooldown")
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<DateTime>("GatherActionSince")
.HasColumnType("TEXT");
b.Property<bool>("IsDead")
.HasColumnType("INTEGER");
@@ -41,7 +44,10 @@ namespace pet_companion_api.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("PetAction")
b.Property<int>("PetBasicAction")
.HasColumnType("INTEGER");
b.Property<int>("PetGatherAction")
.HasColumnType("INTEGER");
b.Property<string>("UserId")
@@ -64,6 +70,15 @@ namespace pet_companion_api.Migrations
b.Property<int>("Intelligence")
.HasColumnType("INTEGER");
b.Property<int>("MaxCharisma")
.HasColumnType("INTEGER");
b.Property<int>("MaxIntelligence")
.HasColumnType("INTEGER");
b.Property<int>("MaxStrength")
.HasColumnType("INTEGER");
b.Property<int>("Strength")
.HasColumnType("INTEGER");

View File

@@ -1,11 +1,12 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace pet_companion_api.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -18,7 +19,12 @@ namespace pet_companion_api.Migrations
Name = table.Column<string>(type: "TEXT", nullable: false),
Class = table.Column<int>(type: "INTEGER", nullable: false),
Level = table.Column<int>(type: "INTEGER", nullable: false),
UserId = table.Column<string>(type: "TEXT", nullable: false)
UserId = table.Column<string>(type: "TEXT", nullable: false),
IsDead = table.Column<bool>(type: "INTEGER", nullable: false),
PetGatherAction = table.Column<int>(type: "INTEGER", nullable: false),
GatherActionSince = table.Column<DateTime>(type: "TEXT", nullable: false),
PetBasicAction = table.Column<int>(type: "INTEGER", nullable: false),
BasicActionCooldown = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
@@ -32,7 +38,10 @@ namespace pet_companion_api.Migrations
PetId = table.Column<string>(type: "TEXT", nullable: false),
Intelligence = table.Column<int>(type: "INTEGER", nullable: false),
Strength = table.Column<int>(type: "INTEGER", nullable: false),
Charisma = table.Column<int>(type: "INTEGER", nullable: false)
Charisma = table.Column<int>(type: "INTEGER", nullable: false),
MaxIntelligence = table.Column<int>(type: "INTEGER", nullable: false),
MaxStrength = table.Column<int>(type: "INTEGER", nullable: false),
MaxCharisma = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{

View File

@@ -22,12 +22,15 @@ namespace pet_companion_api.Migrations
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<DateTime>("ActionSince")
b.Property<DateTime>("BasicActionCooldown")
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<DateTime>("GatherActionSince")
.HasColumnType("TEXT");
b.Property<bool>("IsDead")
.HasColumnType("INTEGER");
@@ -38,7 +41,10 @@ namespace pet_companion_api.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("PetAction")
b.Property<int>("PetBasicAction")
.HasColumnType("INTEGER");
b.Property<int>("PetGatherAction")
.HasColumnType("INTEGER");
b.Property<string>("UserId")
@@ -61,6 +67,15 @@ namespace pet_companion_api.Migrations
b.Property<int>("Intelligence")
.HasColumnType("INTEGER");
b.Property<int>("MaxCharisma")
.HasColumnType("INTEGER");
b.Property<int>("MaxIntelligence")
.HasColumnType("INTEGER");
b.Property<int>("MaxStrength")
.HasColumnType("INTEGER");
b.Property<int>("Strength")
.HasColumnType("INTEGER");