Git Product home page Git Product logo

1822's Introduction

1822 automatic round generator for Google Sheets

This is an automatic round generator for 1822-style games in Google Sheets. The supported games and links to their corresponding Google Sheets documents are below.

The round generator has already been added to each spreadsheet. The spreadsheets linked above are read-only; to use them, save a copy to your own Google Drive with File->"Make a copy" and share the sheet with the other players in your game. The script only works on a desktop computer.

What does it do?

When creating a new round from an existing operating round, the script will create a new sheet with all round-specific information (operational data, stock purchases, miscellaneous income, etc.) cleared.

When creating a new operating round from an existing stock round, the script does the following:

  1. Resolves private bids and assigns the winners as owners
  2. Resolves minor bids, sets the starting value and treasury, and assigns the director
  3. Resolves concession bids and assigns the winners as owners
  4. In phases 1 and 2, trains are exported based on the number of unsold minors. In phases 1-6, an additional train is exported if the minor in bid box 1 is unsold. This can trigger phase changes, which in turn can cause trains to be rusted or discard. The script handles train rusting and discarding.
  5. Increases stock prices for sold-out majors
  6. Creates a new sheet and clears out all round-specific information
  7. Updates private, minor, and concession bid boxes with the next set of companies
  8. Locks the previous sheet to prevent players from inadvertently editing the wrong sheet. Optionally copies cell protections from the previous sheet to prevent players from editing important header/formula cells.

Once the round is generated, an outline for the new round is presented. This can be copied into (e.g.) a Google Doc or forum thread to outline the new round for games played via email/post. My group uses Board18 for the map, a Google Sheets document to manage the game, a Google Docs document for the log, and a Google Group for making "moves" and sending out email alerts.

How do I use it?

  1. Navigate to 1822->"Create new round" from the menu. The first time you run this, you will have to give the script permission to view and modify the sheet, as well as display content in sidebars and dialogs (see the FAQs). The script does not have permission to access any other information related to your Google Drive folder or account.

Menu item

  1. Complete the dialog box with information about the round you would like to generate. There is an option to copy cell protections from the previous sheet. These protections are already added to the SR1 sheet of each template. They are useful for preventing players from accidentally overwriting formula-based cells. However, copying protections is a surprisingly time-consuming task in Google Sheets, so this may add several seconds to the script's runtime.

New round dialog

  1. Click "Create!". If the current round is an operating round, you are done! The new tab will be automatically created. If the current round is a stock round, you will first be asked to confirm what the round generator is doing. This is because creating an operating round from a stock round can be tricky and error-prone (even for the human players!).

Confirm new round

  1. An outline for the new round is printed.

New round outline

Please do not edit cells that serve as headers for other cells (e.g., cells with text like "Trains", "Previous Sheet", etc.). Their contents help the script locate where everything is in the sheet.

FAQs

This app isn't verified!?

No, it's not published. You will have to give the script read/write access to the Google Sheet the first time you run it. On the "This app isn't verified" screen, click "Advanced", then "Go to 1822 (unsafe)".

Unverified app

Clicking "Allow" gives the script the permission to read and write to the specific Google Sheet, as well as display content in prompts and sidebars. The script does not have any other permissions or access to your Google Drive.

The code is visible at Tools->Script editor.

"Unable to locate" something?

This error means that the script can't find a certain group of cells, because the contents of the cell(s) it uses to locate them has changed. Only non-formulaic player, bidding, market, ownership, and operational data should be modified.

"Invalid trains"? What does that mean?

A company's trains must be separated by commas. The following are recognized as valid train types for the games in which they are included: E, 7, 6, 5, 4, 3, 2, L, 2P, P2, 3/2, 3/2P, P3/2, LP, PL, P, P+, +, and G. If any other trains are listed in a company's train cell (or trains from this list that do not belong in a particular game), the script will not run until these train cells are fixed. This is important for properly rusting and discarding trains during phase changes triggered by train exports at the end of a stock round.

I found a bug!

Good job! This is my first project using JavaScript/Google Apps Script, so I suppose we could have seen this coming. Please open an issue for problems that you find. It would be very helpful if you can provide a link to an example sheet for which the round generator behaves incorrectly.

Does this work on mobile?

No. Unfortunately, the user-interface environment invoked by the script is not supported on Google Sheets mobile apps.

1822's People

Contributors

etowle avatar

Stargazers

 avatar  avatar

Watchers

 avatar

1822's Issues

#REF! errors in 1822MX spreadsheet

There are a number of #REF! errors in the 1822MX spreadsheet template. These should be fixed. Also, there is a line of code referencing these existing #REF! errors that should be removed/changed afterwards.

CNoR capitalization issue

There is an issue with the CNoR concession not being found if it is listed in a bid box during an SR. This is because CNoR is not capitalized in the game data, but we convert major names to all uppercase to compare them to the game data list.

Nonexistent players have negative certificate counts

If you have fewer than seven players, the nonexistent players have negative certificate counts. This seems to come about because they are the presidents of all unfloated minors and majors (since the empty string matches the empty string).

Phase change increments in SR

Trains exported during an SR shouldn't necessarily increment the phase by 1. It could be the case that the user forgot to increment the phase previously, so the phase must be changed to match the type of train that was just exported.

Auto-detect game

There should not be a dropdown in the "new round" dialog to select the game. This should be automatically detected using information from the one of the tabs (probably the Setup tab).

Efficiently detect OR/SR

Investigate more efficient ways to detect OR/SR in the round.html dialog. Currently, an expensive read query is made each time a new dropdown item is selected.

NdeM trains over limit

In our current 1822MX game, NdeM was left with five trains after SR2, despite the train limit being four. Perhaps trains are being rusted before the extra bid box 1 train is exported to NdeM.

Option for auto-generating next round player order

After generating a round, there should be an option to see a printout of the player/company order for the new round. This is particularly useful for play-by-post games. It's more or less impossible to get perfectly right for operating rounds, because company share prices can be the same without any way of knowing from the spreadsheet which company should be first. However, we can easily generate a correct or nearly correct ordering.

Request locking previous tab when making new round

It would be nice if the new round script would lock the previous tab when making a new one. We've had lots of issues with players inadvertently entering things on old tabs. This code, added at line 1163 in 1822.gs, is working well for us.

curSheet.protect().setWarningOnly(true);

Hiding acquired minors when starting a new OR

If a minor is acquired in an X.1 OR, our practice is to place a "minor closed" comment (along with a "shares to XX" in the major). If going into an SR this works fine, but if creating a new OR, the sheet hides the minor even though there are still shares.

Permission to build on your work/license

Hi,

Me and a couple of friends are designing our own 18xx game loosely based on 1822 (18OX). To carry on playtesting in the current mess, we're trying to go online and get things set up for online play using Board18. A spreadsheet is a requirement for that. Would it be OK if we forked your 1822 spreadsheet and adapted it to our game? We'd be very grateful and are happy to give credit to you for the original spreadsheet and link to your work for 1822 if we make 18OX public.

Thanks.

Concessions in phases 5-7

The stock round summary should ignore concessions in phases 5-7, rather than treat them like certificates that players can bid on.

Update README images

The README images need to be updated after the new round dialog UI is changed.

Option to opt-out of copying cell protections when creating new sheet

Currently, when creating a new sheet, cell protections are automatically copied from the older sheet. This dominates the script's runtime, and in some cases, may not even be desired behavior. There should be an option for the user to select whether or not they would like to copy protections from the previous sheet.

detectRound hardcoded range

The detectRound() function should not use hardcoded row and column values to get the round status of a page.

Expand to 1822CA

The script should also be able to generate rounds for an 1822CA spreadsheet.

Results object

The Results object should have a show() method. Also, checkIndex() should immediately call this method if the index is -1.

Add error handling

If the script encounters an error, an error dialog should be displayed to the user. Currently, the script may just hang without any indication that it encountered an error. The error should suggest that users open a GitHub issue to report the problem.

Restructure summary/reminders for outline

Currently, we use two lists to print the outline: summary and reminders. This has led to some undesirable formatting problems when generating the round summary. Instead, there should be a third list added so it is easier to keep track of when the outline should use newlines. The structure should be:

Name of new round
    Summary

    Order outline

    Reminders

Move round generation from menu to button

Currently, the option for generating a new round is embedded into the menu bar, which isn't available in the Google Sheets app for iPhone (unsure about iPad). This may be better as a button. It would simplify the "new round" dialog, as the game name and current round name would be implied by the spreadsheet calling the function.

Error discarding invalid trains

We can currently attempt to discard invalid train types (like "M"). The result is an error before the script has a chance to gracefully return the "invalid trains" message. We should:

  • Not even try to discard trains if trainErrors.length > 0
  • Add additional logic so only valid trains (L, 2, 3, ..., 7) can be discarded

Misc spending not cleared out

The Misc player income/expense cells are not cleared out after a new round is generated. This holds for 1822CA; I'm not sure about 1822MX.

Add README

Include description, links to files, setup instructions, etc.

Use formula for starting phase cell

The starting phase cell in the spreadsheet should not need to be updated. It can just indirectly refer to the previous sheet's ending phase.

Redo 'Extra Data' sheet in templates

The 1822MX and 1822CA templates have old, obsolete information in their respective 'Extra Data' sheets. These should be replaced with clear instructions for using the sheet, where this repo is located, etc. We should also consider adding a randomizer to auto-populate the Base sheets.

Auto-update company director

In the templates, the Director row should be filled with automatic formulas to display the name of a company director.

Request: automatic hiding and unhiding of minor columns

It would be nice if only the active minor columns were visible in the spreadsheet: it would save a lot of scrolling. I think only the minors that have been in the bidding boxes should be visible. If you like, I could work on how to do it in the scripts.

Update 1822MX private descriptions

The 1822MX private descriptions (and even assigned numbers) were recently changed in the rules. The spreadsheet should be updated for this.

Apps Script runtime update

Update each script to the new Apps Script runtime. This allows the use of let/const, arrow functions, default parameters, multiline strings, and more. Update the code for these features in obvious places.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.