Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BottlePass Selector #2336

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Travis
  • Loading branch information
carlosrpg committed Aug 1, 2018
commit f83b196522a810194fd8a786f773b730648f8a59
102 changes: 46 additions & 56 deletions content/panorama/scripts/custom_game/hero_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ onPlayerStatChange(null, 'preview_table', CustomNetTables.GetTableValue('hero_se
ReloadCMStatus(CustomNetTables.GetTableValue('hero_selection', 'CMdata'));
UpdatePreviews(CustomNetTables.GetTableValue('hero_selection', 'preview_table'));
changeHilariousLoadingText();
UpdateBottleList()
UpdateBottleList();

$('#ARDMLoading').style.opacity = 0;

Expand Down Expand Up @@ -587,7 +587,7 @@ function PreviewHero (name) {
CreateAbilityPanel(abilityPreview, ability);
});

UpdateBottlePassArcana(name)
UpdateBottlePassArcana(name);
}
selectedhero = name;
selectedherocm = name;
Expand All @@ -601,128 +601,118 @@ function PreviewHero (name) {
}
}

function UpdateBottlePassArcana(heroName){

function UpdateBottlePassArcana (heroName) {
$('#ArcanaSelection').RemoveAndDeleteChildren();

if(heroName !== 'npc_dota_hero_sohei' && heroName !== 'npc_dota_hero_electrician') {
if (heroName !== 'npc_dota_hero_sohei' && heroName !== 'npc_dota_hero_electrician') {
$('#ArcanaPanel').SetHasClass('HasArcana', false);
return;
}
$('#ArcanaPanel').SetHasClass('HasArcana', true);

$.Schedule(0.2, function () {
$.Msg("UpdateBottlePassArcana(" + heroName + ")");
$.Msg('UpdateBottlePassArcana(' + heroName + ')');
var arcanas = null;

var playerID = Game.GetLocalPlayerID();
var special_arcanas = CustomNetTables.GetTableValue('bottlepass', 'special_arcanas');
var arcanas = null;
for (var element in special_arcanas) {
if(special_arcanas[element].PlayerId === playerID){
arcanas = special_arcanas[element].Arcanas;
var specialArcanas = CustomNetTables.GetTableValue('bottlepass', 'special_arcanas');
for (var arcanaIndex in specialArcanas) {
if (specialArcanas[arcanaIndex].PlayerId === playerID) {
arcanas = specialArcanas[arcanaIndex].Arcanas;
}
}

var radio = null;
if (heroName === 'npc_dota_hero_sohei') {

var radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultSoheiSet');
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultSoheiSet');
radio.BLoadLayoutSnippet('ArcanaRadio');
radio.checked = true
radio.checked = true;
radio.hero = heroName;
radio.setName = 'DefaultSet'
radio.setName = 'DefaultSet';

radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'PepsiSoheiSet');
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'PepsiSoheiSet');
radio.BLoadLayoutSnippet('ArcanaRadio');
radio.hero = heroName;
radio.setName = 'PepsiSohei'
radio.setName = 'PepsiSohei';

for (var element in arcanas) {
if(arcanas[element] === 'DBZSohei'){
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DBZSoheiSet');
for (var index in arcanas) {
if (arcanas[index] === 'DBZSohei') {
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DBZSoheiSet');
radio.BLoadLayoutSnippet('ArcanaRadio');
radio.hero = heroName;
radio.setName = 'DBZSohei'
radio.setName = 'DBZSohei';
}
}

} else if (heroName === 'npc_dota_hero_electrician') {

var radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultElectricianSet');
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultElectricianSet');
radio.BLoadLayoutSnippet('ArcanaRadio');
radio.checked = true
radio.checked = true;
radio.hero = heroName;
radio.setName = 'DefaultSet'
radio.setName = 'DefaultSet';

radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'RockElectricianSet');
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'RockElectricianSet');
radio.BLoadLayoutSnippet('ArcanaRadio');
radio.hero = heroName;
radio.setName = 'RockElectrician'
radio.setName = 'RockElectrician';
}
SelectArcana();
});
}

function SelectArcana()
{
function SelectArcana () {
var arcanasList = $('#ArcanaSelection');
if (arcanasList.GetChildCount() > 0)
{
if (arcanasList.GetChildCount() > 0) {
var selectedArcana = $('#ArcanaSelection').Children()[0].GetSelectedButton();

var data = {
Hero: selectedArcana.hero,
Arcana : selectedArcana.setName,
Arcana: selectedArcana.setName,
PlayerId: Game.GetLocalPlayerID()
};

$.Msg('Selecting Arcana ' + data.Arcana +' for Player #' + data.PlayerId + ' for hero ' + data.Hero)
$.Msg('Selecting Arcana ' + data.Arcana + ' for Player #' + data.PlayerId + ' for hero ' + data.Hero);
GameEvents.SendCustomGameEventToServer('arcana_selected', data);
}
}

function UpdateBottleList()
{
function UpdateBottleList () {
$('#BottleSelection').RemoveAndDeleteChildren();
SelectBottle()
//Wait the parent be updated
SelectBottle();
// Wait the parent be updated
$.Schedule(0.2, function () {
var playerID = Game.GetLocalPlayerID();
var special_bottles = CustomNetTables.GetTableValue('bottlepass', 'special_bottles');
var specialBottles = CustomNetTables.GetTableValue('bottlepass', 'special_bottles');
var bottles = null;
for (var element in special_bottles)
{
if(special_bottles[element].PlayerId === playerID){
bottles = special_bottles[element].Bottles;
for (var bottleIndex in specialBottles) {
if (specialBottles[bottleIndex].PlayerId === playerID) {
bottles = specialBottles[bottleIndex].Bottles;
}
}
// Default Bottle
var radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle0');
var radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle0');
radio.BLoadLayoutSnippet('BottleRadio');
radio.checked = true
radio.checked = true;
radio.bottleId = 0;
for (var bottleId in bottles)
{
for (var bottleId in bottles) {
var id = bottles[bottleId];
var radio = $.CreatePanel('RadioButton', $("#BottleSelection"), 'Bottle'+ id);

radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle' + id);
radio.BLoadLayoutSnippet('BottleRadio');
radio.bottleId = id;
}
})
});
}

function SelectBottle()
{
function SelectBottle () {
var bottleId = 0;
var btn = $("#Bottle0");
if(btn != null){
bottleId = $("#Bottle0").GetSelectedButton().bottleId;
var btn = $('#Bottle0');
if (btn != null) {
bottleId = $('#Bottle0').GetSelectedButton().bottleId;
}
var data = {
BottleId: bottleId,
PlayerId: Game.GetLocalPlayerID()
};
$.Msg('Selecting Bottle #' + data.BottleId +' for Player #' +data.PlayerId)
$.Msg('Selecting Bottle #' + data.BottleId + ' for Player #' + data.PlayerId);
GameEvents.SendCustomGameEventToServer('bottle_selected', data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,12 @@ end
function HeroSelection:OnBottleSelected (selectedBottle)
if HeroSelection.SelectedBottle == nil then HeroSelection.SelectedBottle = {} end
HeroSelection.SelectedBottle[selectedBottle.PlayerId] = selectedBottle.BottleId
DevPrintTable(HeroSelection.SelectedBottle)
end

function HeroSelection:OnArcanaSelected (selectedArcana)
if HeroSelection.SelectedArcana == nil then HeroSelection.SelectedArcana = {} end
if HeroSelection.SelectedArcana[selectedArcana.PlayerId] == nil then HeroSelection.SelectedArcana[selectedArcana.PlayerId] = {} end
HeroSelection.SelectedArcana[selectedArcana.PlayerId][selectedArcana.Hero] = selectedArcana.Arcana
DevPrintTable(HeroSelection.SelectedArcana)
end

function HeroSelection:GetSelectedBottleForPlayer(playerId)
Expand Down