Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
a lot more dev for issue #62
Browse files Browse the repository at this point in the history
  • Loading branch information
ontehfritz committed Jun 24, 2014
1 parent 5017dd6 commit a05d808
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/www.mtgdb.info/www.mtgdb.info.userprefs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="www.mtgdb.info/Views/Deck/Deck.cshtml">
<Files>
<File FileName="www.mtgdb.info/Modules/DeckViewerModule.cs" Line="33" Column="16" />
<File FileName="www.mtgdb.info/Views/Deck/Deck.cshtml" Line="19" Column="73" />
<File FileName="www.mtgdb.info/Views/Change/Card.cshtml" Line="16" Column="59" />
<File FileName="www.mtgdb.info/Models/Deck.cs" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Modules/DeckModule.cs" Line="47" Column="49" />
<File FileName="www.mtgdb.info/Helpers/MtgFile.cs" Line="36" Column="26" />
<File FileName="www.mtgdb.info/Views/_Cards.cshtml" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Views/Book.cshtml" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Views/Index.cshtml" Line="34" Column="83" />
<File FileName="www.mtgdb.info/Views/Card.cshtml" Line="24" Column="6" />
<File FileName="www.mtgdb.info/Views/Deck/Deck.cshtml" Line="28" Column="18" />
<File FileName="www.mtgdb.info/Modules/DeckViewerModule.cs" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Models/Views/DeckModel.cs" Line="7" Column="46" />
<File FileName="www.mtgdb.info/Models/Views/DecksModel.cs" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Models/Deck.cs" Line="114" Column="14" />
<File FileName="www.mtgdb.info/Views/_Cards.cshtml" Line="1" Column="76" />
<File FileName="www.mtgdb.info/Views/Deck/_Cards.cshtml" Line="2" Column="1" />
<File FileName="www.mtgdb.info/Views/_Sets.cshtml" Line="1" Column="1" />
<File FileName="www.mtgdb.info/Views/Book.cshtml" Line="50" Column="59" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down
29 changes: 29 additions & 0 deletions src/www.mtgdb.info/www.mtgdb.info/Models/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ public Card[] GetCards()

}

public Card[] GetCards(string type)
{
if(Cards != null)
{
int [] multiverseIds = Cards
.Select(x => x.MultiverseId)
.ToArray();

return mtgDb.GetCards(multiverseIds)
.Where(x => x.Type.ToLower() == type.ToLower())
.ToArray();
}

return null;
}

public Card[] GetSideBarCards()
{
if(Cards != null)
Expand All @@ -113,6 +129,19 @@ public Card[] GetSideBarCards()

return null;
}

public int CardCount(int multiverseId)
{
DeckCard card =
this.Cards.Find(x => x.MultiverseId == multiverseId);

if(card != null)
{
return card.Amount;
}

return 0;
}
}

public class DeckCard
Expand Down
23 changes: 21 additions & 2 deletions src/www.mtgdb.info/www.mtgdb.info/Views/Deck/Deck.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<textarea rows="20" cols="30" name="DeckFile" placeholder="Paste .dec file here">@Model.DeckFile</textarea>
<br />
<button type="submit" class="btn btn-primary btn-lg">Render</button>
<button type="submit" class="btn btn-primary btn-lg">Save</button>
</form>
</div>
<div style="float:left;border: 1px solid black;margin-left: 20px;width:800px;" id="deck">
Expand All @@ -22,9 +21,29 @@
{
foreach(var card in Model.Deck.GetCards())
{
<image src="@card.CardImage" style="width:65px;height:87px;" />
int repeat = (int)System.Math.Ceiling(@Model.Deck.CardCount(card.Id) / 4.0);
for(int times = 0; times < repeat; times++)
{
int top = 0;
string topStyle = string.Format("{0}px;", top);
int max = @Model.Deck.CardCount(card.Id) - (times * 4);
<div style="float:left;margin-left:10px;">
<div style="position:relative;height:140px;">
<image src="@card.CardImage" style="position:relative;width:65px;height:87px; z-index: 0;display:block;"/>
@for(int i = 1; (i < max && i < 4); i++ )
{
top = i * -70;
topStyle = string.Format("{0}px;", top);
<image src="@card.CardImage"
style="position:relative;width:65px;height:87px; z-index: @i; display: block;top:@topStyle" />
}
</div>
</div>
}
}
}

<br style="clear:both;" />
</div>
<div id="spells">
</div>
Expand Down
1 change: 1 addition & 0 deletions src/www.mtgdb.info/www.mtgdb.info/Views/Deck/_Cards.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<MtgDb.Info.Card[]>
1 change: 1 addition & 0 deletions src/www.mtgdb.info/www.mtgdb.info/www.mtgdb.info.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,6 @@
<None Include="Views\Change\CardSet.cshtml" />
<None Include="Views\Change\SetChange.cshtml" />
<None Include="Views\Change\SetLogs.cshtml" />
<None Include="Views\Deck\_Cards.cshtml" />
</ItemGroup>
</Project>

0 comments on commit a05d808

Please sign in to comment.