Skip to content

Commit

Permalink
Merge with current upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
doctorpangloss committed Sep 29, 2018
2 parents 4820a58 + b874de5 commit a3d28c3
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 103 deletions.
4 changes: 2 additions & 2 deletions freeciv-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ mvn flyway:migrate
The following files contains MySQL username and password, and must be set manually
if you are not using vagrant:

freeciv-web/src/main/webapp/META-INF/context.xml.dist (rename to context.xml)
freeciv-web/src/main/webapp/WEB-INF/config.properties.dist (rename to config.properties, contains capcha secret for pbem)
* freeciv-web/src/main/webapp/META-INF/context.xml.dist (rename to context.xml)
* freeciv-web/src/main/webapp/WEB-INF/config.properties.dist (rename to config.properties, contains capcha secret for pbem)


Copyright (C) 2007-2016 Andreas Røsdal.
Expand Down
3 changes: 0 additions & 3 deletions freeciv-web/src/main/webapp/WEB-INF/jsp/fragments/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@
<span onclick="window.location='http://forum.freegamedev.net/viewforum.php?f=97'">Forums</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="https://discord.gg/hgvR9wc">Discord chat</a></li>
<li role="separator" class="divider"></li>
<li><a href="http://forum.freegamedev.net/viewforum.php?f=97">Freeciv-web <fmt:message key="nav-forum"/></a></li>
<li role="separator" class="divider"></li>
<li><a href="https://www.reddit.com/r/freeciv">reddit.com/freeciv</a></li>
</ul>
</li>
<li><a href="/blog/"><fmt:message key="nav-blog"/></a></li>
<%--<li><a href="http://www.freeciv.org/donate.html"><fmt:message key="nav-donate"/></a></li>--%>
<li><a href="https://github.com/freeciv/freeciv-web">Contribute</a></li>
<%--<li class="dropdown">
Expand Down
1 change: 0 additions & 1 deletion freeciv-web/src/main/webapp/WEB-INF/jsp/game/details.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<html lang="en">
<head>
<%@include file="/WEB-INF/jsp/fragments/head.jsp"%>
<script type="text/javascript" src="https://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-553240ed5ba009c1" async="async"></script>
<link rel="stylesheet" href="/css/morris.css" />
<script src="/javascript/libs/raphael-min.js"></script>
<script type="text/javascript" src="/javascript/libs/morris.min.js" ></script>
Expand Down
2 changes: 0 additions & 2 deletions freeciv-web/src/main/webapp/WEB-INF/jsp/game/list.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<head>
<%@include file="/WEB-INF/jsp/fragments/head.jsp"%>

<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-553240ed5ba009c1" async="async"></script>

<script>
(function ($) {
Expand Down
36 changes: 0 additions & 36 deletions freeciv-web/src/main/webapp/WEB-INF/jsp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@
}
.statistics { text-align: center; }
/* Make lastest blog articles look less like a list. */
ul.blog-post-summary { list-style-type: none; }
ul.blog-post-summary > li { margin-bottom: 5px; }
ul.blog-post-summary > li > a {
color: #494A49;
display: block;
}
ul.blog-post-summary > li > a:nth-of-type(1n) { text-decoration: underline; }
ul.blog-post-summary > li > a:nth-of-type(2n) {
font-size: x-small;
text-decoration: none;
}
/* Game launcher */
#game-launcher {
width: 100%;
Expand Down Expand Up @@ -372,30 +360,6 @@
</div> <!-- end youtube -->


<div class="row" id="latest-from-blog">
<div class="col-md-12 container">
<h2><fmt:message key="index-latest-blog"/></h2>
<div class="panel-freeciv">
<ul id="latest-from-blog-articles" class="blog-post-summary">
<!--
loaded dynamically
-->
</ul>
</div>
</div>
</div> <!-- end blog -->

<div class="row" style="padding-top: 30px;">
<div class="col-md-2">
</div>
<div class="col-md-8">
<iframe src="https://discordapp.com/widget?id=354200788785954818&theme=light" width="100%" height="400" allowtransparency="true" frameborder="0"></iframe>
</div>
<div class="col-md-2">
</div>
</div>


<div class="row">
<div class="col-md-12">
<h2><fmt:message key="index-press"/></h2>
Expand Down
10 changes: 0 additions & 10 deletions freeciv-web/src/main/webapp/freeciv-earth/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

</head>
<body>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-553240ed5ba009c1" async="async"></script>

<%@ include file="../WEB-INF/jsp/fragments/header.jsp" %>

<div class="row">
Expand Down Expand Up @@ -79,14 +77,6 @@
</div>
</div>

<div class="row">
<div class="col-lg-12">
<br><br><br>
<br><br><br>
</div>
</div>


<%@ include file="../WEB-INF/jsp/fragments/footer.jsp" %>

</div>
Expand Down
21 changes: 10 additions & 11 deletions freeciv-web/src/main/webapp/javascript/city.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ function is_free_worked(city, tile) {
return (city['tile'] == tile['index']);
}

/**************************************************************************
...
**************************************************************************/
function is_capital(city) {
return city_has_building(city, improvement_id_by_name(B_PALACE_NAME));
}


/**************************************************************************
...
Expand Down Expand Up @@ -597,22 +604,16 @@ function can_city_build_now(pcity, kind, value)
**************************************************************************/
function city_has_building(pcity, improvement_id)
{
for (var z = 0; z < ruleset_control.num_impr_types; z ++) {
if (pcity['improvements'] != null && pcity['improvements'].isSet(z) && z == improvement_id) {
return true;
}
}
return false;
return 0 <= improvement_id && improvement_id < ruleset_control.num_impr_types
&& pcity['improvements'] && pcity['improvements'].isSet(improvement_id);
}


/**************************************************************************
Calculates the turns which are needed to build the requested
improvement in the city. GUI Independent.
**************************************************************************/
function city_turns_to_build(pcity,
target,
include_shield_stock)
function city_turns_to_build(pcity, target, include_shield_stock)
{
var city_shield_surplus = pcity['surplus'][O_SHIELD];
var city_shield_stock = include_shield_stock ? pcity['shield_stock'] : 0;
Expand Down Expand Up @@ -1986,7 +1987,6 @@ function city_keyboard_listener(ev)
break;
}
}

}

/**************************************************************************
Expand Down Expand Up @@ -2035,5 +2035,4 @@ function get_citywalls_scale(pcity)
}

return scale;

}
2 changes: 1 addition & 1 deletion freeciv-web/src/main/webapp/javascript/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ function update_unit_order_commands()
unit_actions["homecity"] = {name: "Change homecity of unit (H)"};
}

if (pcity != null && city_has_building(pcity, 0)) {
if (pcity != null && city_has_building(pcity, improvement_id_by_name(B_AIRPORT_NAME))) {
unit_actions["airlift"] = {name: "Airlift (Shift-L)"};
}

Expand Down
39 changes: 35 additions & 4 deletions freeciv-web/src/main/webapp/javascript/improvement.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,34 @@
***********************************************************************/

var improvements = {};

// incomplete list of (well defined) building names - populate as needed
// Remove in favor of [Effects](https://github.com/freeciv/freeciv-web/issues/208) when implemented.
// IDs are dynamic based on ruleset
const B_AIRPORT_NAME = 'Airport';
const B_PALACE_NAME = 'Palace';

var B_LAST = MAX_NUM_ITEMS;

const improvements = {};
/** @private */
const improvements_name_index = {};

/**************************************************************************
Prepare improvements for use, resetting state from any previous ruleset
**************************************************************************/
function improvements_init()
{
Object.keys(improvements).forEach(k => delete improvements[k]);
Object.keys(improvements_name_index).forEach(k => delete improvements_name_index[k]);
}

/**************************************************************************
Add a new improvement definition
**************************************************************************/
function improvements_add_building(improvement) {
improvements[improvement.id] = improvement;
improvements_name_index[improvement.name] = improvement.id
}

/**************************************************************************
Returns a list containing improvements which are available from a tech.
Expand All @@ -39,7 +62,6 @@ function get_improvements_from_tech(tech_id)
}
}
return result;

}

/**************************************************************************
Expand All @@ -65,7 +87,16 @@ function get_improvement_requirements(improvement_id)
}
}
}

return result;
}

/**************************************************************************
Finds improvement id by exact name, or -1 if not found.
**************************************************************************/
function improvement_id_by_name(name)
{
// 0 is a valid id, so cannot use `|| -1`
return improvements_name_index.hasOwnProperty(name)
? improvements_name_index[name]
: -1;
}
4 changes: 3 additions & 1 deletion freeciv-web/src/main/webapp/javascript/intel_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ function show_intelligence_report_embassy(pplayer)
$("#intel_dialog").remove();
$("<div id='intel_dialog'></div>").appendTo("div#game_page");

const capital = player_capital(pplayer);

var intel_data = {
ruler: pplayer['name'],
government: governments[pplayer['government']]['name'],
capital: '(not implemeted yet)', // TODO
capital: capital ? capital.name : '(capital unknown)',
gold: pplayer['gold'],
tax: pplayer['tax'] + '%',
science: pplayer['science'] + '%',
Expand Down
5 changes: 3 additions & 2 deletions freeciv-web/src/main/webapp/javascript/packhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,13 @@ function handle_ruleset_control(packet)
unit_types = {};
unit_classes = {};
city_rules = {};
improvements = {};
terrains = {};
resources = {};
goods = {};
actions = {};

improvements_init();

/* handle_ruleset_extra defines some variables dinamically */
for (var extra in extras) {
var ename = extras[extra]['name'];
Expand Down Expand Up @@ -1248,7 +1249,7 @@ function handle_ruleset_city(packet)
/* 100% complete */
function handle_ruleset_building(packet)
{
improvements[packet['id']] = packet;
improvements_add_building(packet);
}

function handle_ruleset_unit_class(packet)
Expand Down
23 changes: 22 additions & 1 deletion freeciv-web/src/main/webapp/javascript/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function get_invalid_username_reason(username)
{
if (username == null || username.length == 0) {
return "empty";
} else if (username.length <= 2 ) {
} else if (username.length <= 2) {
return "too short";
} else if (username.length >= 32) {
return "too long";
Expand All @@ -271,3 +271,24 @@ function get_invalid_username_reason(username)
}
return null;
}

/**************************************************************************
returns the the player's capital city, or undefined
**************************************************************************/
function player_capital(player)
{
for (const city_id in cities) {
const city = cities[city_id];
if (does_player_own_city(player, city) && is_capital(city)) {
return city;
}
}
}

/**************************************************************************
returns true if the specified player owns the specified city
**************************************************************************/
function does_player_own_city(player, city)
{
return city_owner_player_id(city) === player.playerno;
}
30 changes: 1 addition & 29 deletions freeciv-web/src/main/webapp/static/javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ $(document).ready(function () {
(function ($) {

$(function () {
// loadBlog();
loadBestOfPlayByEmail();
displayStore();

Expand All @@ -13,33 +12,6 @@ $(document).ready(function () {
}
});

function loadBlog() {
// TODO: rename /fpfeed.json to /feed
$.getJSON('/fpfeed.json', function(data) {
var MAX_ELEMENTS = 5;
var root = document.getElementById('latest-from-blog-articles');
data.forEach(function (article, i) {
if (i >= MAX_ELEMENTS) {
return;
}
var item = document.createElement('li');
var title = document.createElement('a');
var date = document.createElement('a');

title.href = article.permalink;
title.innerHTML = article.title;
date.href = article.permalink;
date.innerHTML = article.date;

item.appendChild(title);
item.appendChild(date);
root.appendChild(item);
});
}).fail(function () {
document.getElementById('latest-from-blog').style.display = 'none';
})
}

function loadBestOfPlayByEmail() {

var clearContent = function () {
Expand Down Expand Up @@ -80,4 +52,4 @@ $(document).ready(function () {


})($)
});
});

0 comments on commit a3d28c3

Please sign in to comment.