Skip to content

Commit

Permalink
Support for tames frozen in cryopods.
Browse files Browse the repository at this point in the history
Improvements to base stats and other fields useful for breeding.
  • Loading branch information
mxtsdev committed Feb 10, 2020
1 parent 9f1a8c8 commit c9b734b
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,6 @@ FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
ModelManifest.xml

!libs/*.pdb
2 changes: 1 addition & 1 deletion ArkBot/Data/ArkSpeciesStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public SpeciesStat GetSpecies(string[] speciesaliases)
var multipliers = ArkServerMultipliers.Instance.Data?.GetStatMultipliers(stat);
var stats = SpeciesStats?.FirstOrDefault(x => speciesaliases.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.Stats;

if (multipliers == null || multipliers.Length != 4 || stats == null) return null;
if (multipliers == null || multipliers.Length != 4 || stats == null || stats[index] == null) return null;

//stats = new double[8].Select((x, i) =>
//{
Expand Down
18 changes: 12 additions & 6 deletions ArkBot/WebApi/Controllers/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,14 @@ internal static List<TamedCreatureViewModel> BuildCreatureViewModelsForPlayerId(
{
var player = context.Players?.FirstOrDefault(x => x.Id == playerId);
var playercreatures = context.NoRafts.Where(x => x.TargetingTeam == playerId || (x.OwningPlayerId.HasValue && x.OwningPlayerId == playerId)).ToArray();
var playercreatures_cryo = player?.Items?.OfType<ArkItemCryopod>().Where(x => x.Dino != null).Select(x => x.Dino).ToArray() ?? new ArkTamedCreature[] {};
var tribe = player != null ? player.Tribe : context.Tribes?.FirstOrDefault(x => x.MemberIds.Contains((int)playerId));
var tribecreatures = tribe != null ? context.NoRafts.Where(x => x.TargetingTeam == tribe.Id && !playercreatures.Any(y => y.Id == x.Id)).ToArray() : new ArkTamedCreature[] { };
foreach (var item in playercreatures.Select(x => new { c = x, o = "player" }).Concat(tribecreatures.Select(x => new { c = x, o = "tribe" })))
var tribecreatures_cryo = tribe?.Items?.OfType<ArkItemCryopod>().Where(x => x.Dino != null).Select(x => x.Dino).ToArray() ?? new ArkTamedCreature[] { };
foreach (var item in playercreatures.Select(x => new { c = x, o = "player", cryo = false })
.Concat(playercreatures_cryo.Select(x => new { c = x, o = "player", cryo = true }))
.Concat(tribecreatures.Select(x => new { c = x, o = "tribe", cryo = false }))
.Concat(tribecreatures_cryo.Select(x => new { c = x, o = "tribe", cryo = true })))
{

var currentFood = item.c.CurrentStatusValues?.Length > 4 ? item.c.CurrentStatusValues[4] : null;
Expand Down Expand Up @@ -258,14 +263,15 @@ internal static List<TamedCreatureViewModel> BuildCreatureViewModelsForPlayerId(
BabyAge = item.c.IsBaby ? item.c.BabyAge : null,
Imprint = item.c.DinoImprintingQuality,
FoodStatus = foodStatus,
Latitude = item.c.Location?.Latitude,
Longitude = item.c.Location?.Longitude,
TopoMapX = item.c.Location?.TopoMapX,
TopoMapY = item.c.Location?.TopoMapY,
Latitude = item.cryo ? null : item.c.Location?.Latitude,
Longitude = item.cryo ? null : item.c.Location?.Longitude,
TopoMapX = item.cryo ? null : item.c.Location?.TopoMapX,
TopoMapY = item.cryo ? null : item.c.Location?.TopoMapY,
NextMating = !item.c.IsBaby && item.c.Gender == ArkCreatureGender.Female ? item.c.NextAllowedMatingTimeApprox : null,
BabyFullyGrown = babyFullyGrownTimeApprox,
BabyNextCuddle = item.c.BabyNextCuddleTimeApprox,
OwnerType = item.o
OwnerType = item.o,
InCryopod = item.cryo
};
if (incBaseStats)
{
Expand Down
1 change: 1 addition & 0 deletions ArkBot/WebApi/Model/TamedCreatureViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public TamedCreatureViewModel()
public DateTime? BabyFullyGrown { get; set; }
public DateTime? BabyNextCuddle { get; set; }
public string OwnerType { get; set; }
public bool InCryopod { get; set; }

// these fields are only set when creature is owned by the authenticated person making the request
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Expand Down
2 changes: 1 addition & 1 deletion ArkBot/WebApp/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
<h3 class="w3-text-grey">Loading...</h3>
</div>
</section>
<script type="text/javascript" src="inline.c034f60d1641851a325c.bundle.js"></script><script type="text/javascript" src="polyfills.c2c650e443c940acda1b.bundle.js"></script><script type="text/javascript" src="scripts.01c3505ddbe0d20e9ed0.bundle.js"></script><script type="text/javascript" src="vendor.f8d4a57af80469b13c5c.bundle.js"></script><script type="text/javascript" src="main.530f7ebf959a6f5fc07c.bundle.js"></script></body>
<script type="text/javascript" src="inline.b8f54d98a74080feb377.bundle.js"></script><script type="text/javascript" src="polyfills.c2c650e443c940acda1b.bundle.js"></script><script type="text/javascript" src="scripts.01c3505ddbe0d20e9ed0.bundle.js"></script><script type="text/javascript" src="vendor.975862c22a3936589bf5.bundle.js"></script><script type="text/javascript" src="main.b843992344f818a8e8f4.bundle.js"></script></body>
</html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ArkBot/WebApp/dist/main.530f7ebf959a6f5fc07c.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions ArkBot/WebApp/dist/main.b843992344f818a8e8f4.bundle.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ArkBot/WebApp/src/app/player/player.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.stat-cell {
padding: 3px 2px;
}

.stat-item {
padding: 5px 0px;
}
93 changes: 73 additions & 20 deletions ArkBot/WebApp/src/app/player/player.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,34 @@ <h2 class="theme-text-d1">Servers</h2>
<!--<th>ClassName</th>-->
<th style="cursor: pointer;" title="Sort by Species" (click)="setCreaturesSort('species')">Species</th>
<!--<th>Aliases</th>-->
<th style="cursor: pointer;" title="Sort by Gender" (click)="setCreaturesSort('gender')">Gender</th>
<ng-container *ngIf="!activeCreaturesMode('stats')">
<th style="cursor: pointer;" title="Sort by Gender" (click)="setCreaturesSort('gender')">Gender</th>
</ng-container>
<th style="cursor: pointer;" title="Sort by Base Level" (click)="setCreaturesSort('base_level')">Base Level</th>
<th style="cursor: pointer;" title="Sort by Level" (click)="setCreaturesSort('level')">Level</th>
<ng-container *ngIf="activeCreaturesMode('status')">
<th style="cursor: pointer;" title="Sort by Level" (click)="setCreaturesSort('level')">Level</th>
<th style="cursor: pointer;" title="Sort by Imprint" (click)="setCreaturesSort('imprint')">Imprint</th>
<th style="cursor: pointer;" title="Sort by Food" (click)="setCreaturesSort('food')">Food</th>
<th style="cursor: pointer;" title="Sort by Latitude" (click)="setCreaturesSort('latitude')">Lat</th>
<th style="cursor: pointer;" title="Sort by Longitude" (click)="setCreaturesSort('longitude')">Lng</th>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('status') || activeCreaturesMode('stats')">
<th style="cursor: pointer;" title="Sort by In Cryopod" (click)="setCreaturesSort('in_cryopod')">Cryopod</th>
<th>Status</th>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('status')">
<th style="cursor: pointer;" title="Sort by Owner" (click)="setCreaturesSort('owner')">Owner</th>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('stats')">
<th style="cursor: pointer;" title="Sort by Health" (click)="setCreaturesSort('stat_health')">HP</th>
<th style="cursor: pointer;" title="Sort by Stamina" (click)="setCreaturesSort('stat_stamina')">ST</th>
<th style="cursor: pointer;" title="Sort by Oxygen" (click)="setCreaturesSort('stat_oxygen')">OX</th>
<th style="cursor: pointer;" title="Sort by Food" (click)="setCreaturesSort('stat_food')">FO</th>
<th style="cursor: pointer;" title="Sort by Weight" (click)="setCreaturesSort('stat_weight')">WE</th>
<th style="cursor: pointer;" title="Sort by Melee" (click)="setCreaturesSort('stat_melee')">ME</th>
<th style="cursor: pointer;" title="Sort by Speed" (click)="setCreaturesSort('stat_speed')">SP</th>
<th style="cursor: pointer;" title="Sort by Num Top Stats" (click)="setCreaturesSort('num_top_stats')">Top</th>
<th style="cursor: pointer;" title="Sort by Gender" (click)="setCreaturesSort('gender')">Gender</th>
<th style="cursor: pointer; text-align: center;" title="Sort by Health" (click)="setCreaturesSort('stat_health')">HP</th>
<th style="cursor: pointer; text-align: center" title="Sort by Stamina" (click)="setCreaturesSort('stat_stamina')">ST</th>
<th style="cursor: pointer; text-align: center" title="Sort by Oxygen" (click)="setCreaturesSort('stat_oxygen')">OX</th>
<th style="cursor: pointer; text-align: center" title="Sort by Food" (click)="setCreaturesSort('stat_food')">FO</th>
<th style="cursor: pointer; text-align: center" title="Sort by Weight" (click)="setCreaturesSort('stat_weight')">WE</th>
<th style="cursor: pointer; text-align: center" title="Sort by Melee" (click)="setCreaturesSort('stat_melee')">ME</th>
<th style="cursor: pointer; text-align: center" title="Sort by Speed" (click)="setCreaturesSort('stat_speed')">SP</th>
<!--<th></th>-->
</ng-container>
<ng-container *ngIf="activeCreaturesMode('ids')">
Expand All @@ -102,16 +111,18 @@ <h2 class="theme-text-d1">Servers</h2>
</tr>
</thead>
<tbody>
<tr *ngIf="!(filteredCreatures?.length > 0)"><td [colSpan]="(activeCreaturesMode('ids') ? 6 : 11)">No matching creatures...</td></tr>
<tr *ngIf="!(filteredCreatures?.length > 0)"><td [colSpan]="(activeCreaturesMode('ids') ? 6 : activeCreaturesMode('stats') ? 14 : 12)">No matching creatures...</td></tr>
<tr *ngFor="let creature of filteredCreatures">
<td>{{creature.Name}}</td>
<!--<td>{{creature.ClassName}}</td>-->
<td>{{creature.Species}}</td>
<!--<td>{{creature.Aliases}}</td>-->
<td>{{creature.Gender}}</td>
<ng-container *ngIf="!activeCreaturesMode('stats')">
<td>{{creature.Gender}}</td>
</ng-container>
<td>{{creature.BaseLevel}}</td>
<td><span *ngIf="creature.BaseLevel != creature.Level">{{creature.Level}}</span></td>
<ng-container *ngIf="activeCreaturesMode('status')">
<td><span *ngIf="creature.BaseLevel != creature.Level">{{creature.Level}}</span></td>
<td>{{creature.Imprint | percent:'1.0-0'}}</td>
<td>
<div *ngIf="creature.FoodStatus != null" class="theme-lighter-c1-bg w3-round" style="width: 6em; position: relative;">
Expand All @@ -121,8 +132,12 @@ <h2 class="theme-text-d1">Servers</h2>
</td>
<td>{{creature.Latitude | number:'1.1-1'}}</td>
<td>{{creature.Longitude | number:'1.1-1'}}</td>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('status') || activeCreaturesMode('stats')">
<td>{{creature.InCryopod ? 'Yes' : ''}}</td>
<td>
<span *ngIf="haveMatingCooldown(creature)">Next mating {{dataService.toRelativeDate(creature.NextMating)}}</span>
<span *ngIf="readyForMating(creature)">Ready for mating</span>
<div *ngIf="creature.BabyAge != null">
<div>
<div class="w3-cell w3-cell-middle">Baby</div>
Expand All @@ -136,17 +151,55 @@ <h2 class="theme-text-d1">Servers</h2>
</div>
</div>
</td>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('status')">
<td>{{creature.OwnerType}}</td>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('stats')">
<td>{{creature.BaseStats?.Health}}</td>
<td>{{creature.BaseStats?.Stamina}}</td>
<td>{{creature.BaseStats?.Oxygen}}</td>
<td>{{creature.BaseStats?.Food}}</td>
<td>{{creature.BaseStats?.Weight}}</td>
<td>{{creature.BaseStats?.Melee}}</td>
<td>{{creature.BaseStats?.MovementSpeed}}</td>
<!--<td><i class="material-icons w3-medium" style="cursor: pointer;" (click)="copyCreature(creature)">content_copy</i></td>-->
<td>{{numTopStats(creature)}}</td>
<td>{{creature.Gender}}</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Health}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Health')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Stamina}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Stamina')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Oxygen}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Oxygen')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Food}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Food')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Weight}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Weight')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.Melee}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'Melee')">&nbsp;</div>
</div>
</td>
<td class="stat-cell">
<div class="w3-round" style="position: relative;">
<div class="stat-item" style="position: absolute; left: 50%; transform: translate(-50%, 0%);">{{creature.BaseStats?.MovementSpeed}}</div>
<div class="w3-round stat-item" style="width: 100%;" [style.backgroundColor]="getColorForSpeciesStat(creature, 'MovementSpeed')">&nbsp;</div>
</div>
</td>
</ng-container>
<ng-container *ngIf="activeCreaturesMode('ids')">
<td>{{creature.Id1}}</td>
Expand Down
Loading

0 comments on commit c9b734b

Please sign in to comment.