Skip to content

Commit

Permalink
Merge pull request #3 from Kamalisk/arkham
Browse files Browse the repository at this point in the history
Fork update
  • Loading branch information
Sarnetsky committed Aug 31, 2020
2 parents 6195221 + 7de622e commit 647e4f4
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 246 deletions.
38 changes: 21 additions & 17 deletions src/AppBundle/Command/ImportStdCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,25 +491,8 @@ protected function importCardsJsonFile(\SplFileInfo $fileinfo, $special="")

]);
if($card) {
if ($card->getName()){
$card->setRealName($card->getName());
}
if ($card->getTraits()){
$card->setRealTraits($card->getTraits());
}
if ($card->getText()){
$card->setRealText($card->getText());
}
$result[] = $card;
$this->em->persist($card);
if (isset($cardData['back_link'])){
// if we have back link, store the reference here
$this->links[] = ['card_id'=> $card->getCode(), 'target_id'=> $cardData['back_link']];
}
if (isset($cardData['alternate_of'])){
// if we have back link, store the reference here
$this->links[] = ['card_id'=> $card->getCode(), 'target_id'=> $cardData['alternate_of'], 'type' => 'alternate_of'];
}
}
}

Expand Down Expand Up @@ -690,6 +673,27 @@ protected function getEntityFromData($entityName, $data, $mandatoryKeys, $foreig

// special case for Card
if($entityName === 'AppBundle\Entity\Card') {
if ($entity->getName()){
$entity->setRealName($entity->getName());
}
if ($entity->getTraits()){
$entity->setRealTraits($entity->getTraits());
}
if ($entity->getText()){
$entity->setRealText($entity->getText());
}
if ($entity->getSlot()){
$entity->setRealSlot($entity->getSlot());
}

if (isset($data['back_link'])){
// if we have back link, store the reference here
$this->links[] = ['card_id'=> $entity->getCode(), 'target_id'=> $data['back_link']];
}
if (isset($data['alternate_of'])){
// if we have back link, store the reference here
$this->links[] = ['card_id'=> $entity->getCode(), 'target_id'=> $data['alternate_of'], 'type' => 'alternate_of'];
}
// calling a function whose name depends on the type_code
$functionName = 'import' . $entity->getType()->getName() . 'Data';
$this->$functionName($entity, $data);
Expand Down
7 changes: 4 additions & 3 deletions src/AppBundle/Command/ImportTransCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function configure()
}
protected function execute(InputInterface $input, OutputInterface $output)
{
ini_set('memory_limit','1024M');
$this->em = $this->getContainer()->get('doctrine')->getEntityManager();
$this->output = $output;

Expand All @@ -52,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

//$things = ['faction', 'type', 'subtype', 'cycle', 'pack', 'campaign', 'scenario', 'encounter'];
$things = ['faction', 'type', 'subtype', 'cycle', 'pack'];
$things = ['faction', 'type', 'subtype', 'cycle', 'pack', 'encounter'];

foreach($locales as $locale)
{
Expand Down Expand Up @@ -121,8 +122,8 @@ protected function importCardsJsonFile(\SplFileInfo $fileinfo, $locale)
'subname',
'back_name',
'back_flavor',
'back_text'/*,
'slot'*/
'back_text',
'slot'
]);
}

Expand Down
42 changes: 42 additions & 0 deletions src/AppBundle/Entity/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public function serialize() {
'linked_to',
'alternate_of'
];

$transFields = [
'real_name',
'real_slot',
'real_text',
'real_traits'
];

switch($this->type->getCode()) {
case 'asset':
Expand Down Expand Up @@ -153,6 +160,12 @@ public function serialize() {
$serialized[$externalField.'_code'] = $this->$getter()->getCode();
}
}

foreach($transFields as $transField) {
$getter = 'get' . $this->snakeToCamel($transField);
$serialized[$transField] = $this->$getter();
if(!isset($serialized[$transField]) || $serialized[$transField] === '') unset($serialized[$transField]);
}

ksort($serialized);
return $serialized;
Expand Down Expand Up @@ -2175,4 +2188,33 @@ public function getBondedCount()
{
return $this->bondedCount;
}
/**
* @var string
*/
private $realSlot;


/**
* Set realSlot.
*
* @param string $realSlot
*
* @return Card
*/
public function setRealSlot($realSlot)
{
$this->realSlot = $realSlot;

return $this;
}

/**
* Get realSlot.
*
* @return string
*/
public function getRealSlot()
{
return $this->realSlot;
}
}
48 changes: 47 additions & 1 deletion src/AppBundle/Entity/Encounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AppBundle\Entity;

class Encounter implements \Serializable
class Encounter implements \Gedmo\Translatable\Translatable, \Serializable
{
public function serialize() {
return [
Expand Down Expand Up @@ -143,4 +143,50 @@ public function getCards()
{
return $this->cards;
}

/**
* Add scenario.
*
* @param \AppBundle\Entity\Scenario $scenario
*
* @return Encounter
*/
public function addScenario(\AppBundle\Entity\Scenario $scenario)
{
$this->scenarios[] = $scenario;

return $this;
}

/**
* Remove scenario.
*
* @param \AppBundle\Entity\Scenario $scenario
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeScenario(\AppBundle\Entity\Scenario $scenario)
{
return $this->scenarios->removeElement($scenario);
}

/**
* Get scenarios.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getScenarios()
{
return $this->scenarios;
}

/*
* I18N vars
*/
private $locale = 'en';

public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
}
2 changes: 1 addition & 1 deletion src/AppBundle/Helper/DeckValidationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function findProblem($deck)
if($investigator) {
$req = $this->parseReqString($investigator->getDeckRequirements());
if ($req && $req['size']){
if($deck->getSlots()->getDrawDeck()->countCards() < $req['size']) {
if($deck->getSlots()->getDrawDeck()->countCards() < 20) {
return 'too_few_cards';
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/AppBundle/Resources/config/doctrine/Card.orm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ AppBundle\Entity\Card:
type: string
length: 50
nullable: true
gedmo:
- translatable
realSlot:
type: string
length: 50
nullable: true
stage:
type: smallint
nullable: true
Expand Down
7 changes: 6 additions & 1 deletion src/AppBundle/Resources/config/doctrine/Encounter.orm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
AppBundle\Entity\Encounter:
type: entity
table: Encounter
gedmo:
translation:
locale: locale
oneToMany:
cards:
targetEntity: Card
Expand All @@ -25,7 +28,9 @@ AppBundle\Entity\Encounter:
type: string
length: 1024
nullable: false
gedmo:
- translatable
uniqueConstraints:
encounter_code_idx:
columns: [ code ]


2 changes: 1 addition & 1 deletion src/AppBundle/Resources/public/js/app.card_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function fill_modal (code) {
}
var qtyelt = modal.find('.modal-ignore');

if(qtyelt && card.maxqty && card.code == "05040") {
if(qtyelt && card.maxqty && (card.code == "05040" || card.real_traits.indexOf('Fortune.') !== -1 || card.real_traits.indexOf('Gambit.') !== -1 ) ) {
qtyelt.closest('.modal-deck-ignore').show();
var qty = '';
for(var i=0; i<=card.maxqty; i++) {
Expand Down
24 changes: 18 additions & 6 deletions src/AppBundle/Resources/public/js/app.deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ deck.get_layout_data = function get_layout_data(options) {
if (card.deck_requirements.size){
size = card.deck_requirements.size;
}
if (deck.meta && deck.meta.alternate_back) {
var alternate = app.data.cards.findById(deck.meta.alternate_back);
if (alternate && alternate.deck_requirements.size) {
size = alternate.deck_requirements.size;
}
}
if (deck.meta && deck.meta.deck_size_selected){
size = parseInt(deck.meta.deck_size_selected, 10);
}
Expand Down Expand Up @@ -691,8 +697,8 @@ deck.get_layout_data_one_section = function get_layout_data_one_section(query, d
var $div = deck.create_card(card);


if (card.slot && slots[card.slot]){
slots[card.slot].push($div);
if (card.real_slot && slots[card.real_slot]){
slots[card.real_slot].push($div);
} else {
slots["Other"].push($div);
}
Expand Down Expand Up @@ -762,7 +768,7 @@ deck.create_card = function create_card(card){
}
}

if (card.name == "Random Basic Weakness" && $("#special-collection").length > 0 ){
if (card.code == "01000" && $("#special-collection").length > 0 ){
$div.append(' <a class="fa fa-random" title="Replace with randomly selected weakness from currently selected packs" data-random="'+card.code+'"> <span ></span></a> ');
}
return $div;
Expand Down Expand Up @@ -864,14 +870,14 @@ deck.get_copies_and_deck_limit = function get_copies_and_deck_limit() {
var value = copies_and_deck_limit[card.real_name];
if(!value) {
copies_and_deck_limit[card.real_name] = {
nb_copies: card.indeck,
nb_copies: card.indeck - card.ignore,
deck_limit: card.deck_limit
};
if (typeof card.real_text !== 'undefined' && card.real_text.indexOf('Myriad.') !== -1) {
copies_and_deck_limit[card.real_name].deck_limit = 3;
}
} else {
value.nb_copies += card.indeck;
value.nb_copies += card.indeck - card.ignore;
value.deck_limit = Math.min(card.deck_limit, value.deck_limit);
if (typeof card.real_text !== 'undefined' && card.real_text.indexOf('Myriad.') !== -1) {
value.deck_limit = 3;
Expand All @@ -895,6 +901,12 @@ deck.get_problem = function get_problem() {
if (card.deck_requirements.size){
size = card.deck_requirements.size;
}
if (deck.meta && deck.meta.alternate_back) {
var alternate = app.data.cards.findById(deck.meta.alternate_back);
if (alternate && alternate.deck_requirements.size) {
size = alternate.deck_requirements.size;
}
}
if (deck.meta && deck.meta.deck_size_selected){
size = parseInt(deck.meta.deck_size_selected, 10);
}
Expand Down Expand Up @@ -1100,7 +1112,7 @@ deck.can_include_card = function can_include_card(card, limit_count, hard_count)
for(var j = 0; j < option.slot.length; j++){
var slot = option.slot[j];

if (card.slot && card.slot.toUpperCase().indexOf(slot.toUpperCase()) !== -1){
if (card.real_slot && card.real_slot.toUpperCase().indexOf(slot.toUpperCase()) !== -1){
slot_valid = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Resources/public/js/ui.deckedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ ui.select_basic_weakness = function select_basic_weakness() {
weaknesses.forEach(function (card){
//console.log(card);

if($("[name="+card.pack_code+"]").is(":checked") && card.name != "Random Basic Weakness" && card.indeck < card.maxqty){
if($("[name="+card.pack_code+"]").is(":checked") && card.code != "01000" && card.indeck < card.maxqty){
filtered_weaknesses.push(card);
}
});
Expand Down
52 changes: 26 additions & 26 deletions src/AppBundle/Resources/translations/FOSUserBundle.ru.xlf
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="330e10079eb2496038ea24d1fed8803d" resname="Your account is not awaiting confirmation">
<source>Your account is not awaiting confirmation</source>
<target>Ваш аккаунт не ожидает подтверждения</target>
</trans-unit>
<trans-unit id="be167c33564ffd5dd49f2c766dbefade" resname="If you forgot your password">
<source>If you forgot your password</source>
<target>Если вы забыли свой пароль</target>
</trans-unit>
<trans-unit id="a4ea91cd0d1ea33d8113457644dd6157" resname="click here">
<source>click here</source>
<target>нажмите здесь</target>
</trans-unit>
<trans-unit id="1068a744de8330e8267289fcae54b2e6" resname="otherwise log in">
<source>otherwise log in</source>
<target>в противном случае войдите (log in)</target>
</trans-unit>
</body>
</file>
</xliff>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="ru" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="67_RjP." resname="Your account is not awaiting confirmation">
<source>Your account is not awaiting confirmation</source>
<target>Ваш аккаунт не ожидает подтверждения</target>
</trans-unit>
<trans-unit id="iqREVDn" resname="If you forgot your password">
<source>If you forgot your password</source>
<target>Если вы забыли свой пароль</target>
</trans-unit>
<trans-unit id="nh5NYWV" resname="click here">
<source>click here</source>
<target>нажмите здесь</target>
</trans-unit>
<trans-unit id="olmUwYV" resname="otherwise log in">
<source>otherwise log in</source>
<target>в противном случае войдите (log in)</target>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit 647e4f4

Please sign in to comment.