Commits

Pedro Ferreira  committed b3222aa

- add create_release script (for the website)
- add loading message (when loading the images with preloadjs)
- fix, use BASE_URL instead of G.BASE_URL (for the script to work)
- fix, clear the selectedCards array of each Player

  • Participants
  • Parent commits 5e735e1

Comments (0)

Files changed (7)

File create_release/copy_files_config.txt

+{
+    "resultingFolder": "hearts_solitaire",
+    "basePath": "..",
+    "files":
+        [
+            "css/",
+            "images/",
+            "libraries/",
+            "manifest.json"
+        ]
+}

File create_release/create_server_template.py

+# python3
+
+import os.path
+import argparse
+import sys
+
+sys.path.append( 'C:/Users/drk/Dropbox/projects/' )
+
+
+import create_release_script.create_server_template as create_server_template
+
+
+    # relative paths
+default_indexPath = '../index.html'
+default_appName = 'hearts_solitaire'
+default_copyToPath = 'C:/Users/drk/Dropbox/projects/website/templates/{}/'.format( default_appName )
+
+
+def go( indexPath= default_indexPath,
+        appName= default_appName,
+        copyToPath= default_copyToPath,
+        templateName= None ):
+
+    indexPath = os.path.realpath( indexPath )
+    copyToPath = os.path.realpath( copyToPath )
+
+    create_server_template.go( indexPath, appName, copyToPath, templateName )
+
+
+
+if __name__ == '__main__':
+
+    parser = argparse.ArgumentParser( description= 'Create the server template.' )
+
+    parser.add_argument( 'indexPath', nargs= '?', default= default_indexPath )
+    parser.add_argument( 'appName', nargs= '?', default= default_appName )
+    parser.add_argument( 'copyToPath', nargs= '?', default= default_copyToPath )
+
+    args = parser.parse_args()
+
+    go( args.indexPath, args.appName, args.copyToPath )

File create_release/main.py

+# python3
+
+import argparse
+import sys
+import os.path
+
+sys.path.append( 'C:/Users/drk/Dropbox/projects/' )
+
+import create_release_script.main as main
+
+
+    # relative paths
+default_htmlFile = "../index.html"
+default_concatenateConfig = "concatenate_config.txt"
+default_copyFilesConfig = "copy_files_config.txt"
+default_resultingFolder = "hearts_solitaire"
+
+
+def go( htmlFile= default_htmlFile,
+        copyFilesConfig= default_copyFilesConfig,
+        concatenateConfig= default_concatenateConfig,
+        resultingFolder= default_resultingFolder ):
+
+        # absolute paths
+    htmlFile = os.path.realpath( htmlFile )
+    copyFilesConfig = os.path.realpath( copyFilesConfig )
+    concatenateConfig = os.path.realpath( concatenateConfig )
+    resultingFolder = os.path.realpath( resultingFolder )
+
+    baseDirectory = os.path.realpath( '' )
+
+
+    main.go( htmlFile, copyFilesConfig, concatenateConfig, resultingFolder, baseDirectory )
+
+
+    
+
+if __name__ == '__main__':    
+
+    parser = argparse.ArgumentParser( description= 'Generate the release files of the program.' )
+
+    parser.add_argument( 'htmlFile', help= 'Path to the index.html.', nargs= '?', default= default_htmlFile )
+    parser.add_argument( 'copyFilesConfig', help= 'Path to the configuration file that tells which files to copy.', nargs= '?', default= default_copyFilesConfig )
+    parser.add_argument( 'concatenateConfig', help= 'Path to the configuration file to tell which files to concatenate (and the order).', nargs= '?', default= default_concatenateConfig )
+    parser.add_argument( 'resultingFolder', help= "Name of the folder that is created in the current path and contains the copies.", nargs= "?", default= default_resultingFolder )
+
+
+    args = parser.parse_args()
+
+    go( args.htmlFile, args.copyFilesConfig, args.concatenateConfig, args.resultingFolder )

File css/style.css

     background-color: #edcf90;
     }
 
-
+#LoadMessage
+    {
+    position: fixed;
+    text-align: center;
+    }
 
     <link rel="stylesheet" href="libraries/smoothness/jquery-ui-1.10.4.custom.min.css" />
 
-
+    <!-- CONCATENATE_START -->
     <script type="text/javascript" src="scripts/utilities.js"></script>
     <script type="text/javascript" src="scripts/move_animation.js"></script>
     <script type="text/javascript" src="scripts/message.js"></script>
     <script type="text/javascript" src="scripts/game_menu.js"></script>
     <script type="text/javascript" src="scripts/statistics.js"></script>
     <script type="text/javascript" src="scripts/main.js"></script>
+    <!-- CONCATENATE_END -->
 
     <link rel="stylesheet" href="css/style.css" />
 </head>
     <div id="RoundEnded" title="Round ended"></div>
 
     <div id="Message"></div>
+    <div id="LoadMessage"></div>
 </body>
 </html>

File scripts/main.ts

         STAGE: null,
         FPS: 30,
         PRELOAD: null,
-        BASE_URL: '',
         DEBUG: false
     };
 
+var BASE_URL = '';
+
 window.onload = function()
 {
 G.CANVAS = document.querySelector( '#MainCanvas' );
 G.PRELOAD = new createjs.LoadQueue();
 
 var manifest = [
-        { id: 'card_back', src: G.BASE_URL + 'images/card_back_black.png' },
+        { id: 'card_back', src: BASE_URL + 'images/card_back_black.png' },
 
-        { id: 'ace_of_clubs', src: G.BASE_URL + 'images/ace_of_clubs.png' },
-        { id: 'two_of_clubs', src: G.BASE_URL + 'images/2_of_clubs.png' },
-        { id: 'three_of_clubs', src: G.BASE_URL + 'images/3_of_clubs.png' },
-        { id: 'four_of_clubs', src: G.BASE_URL + 'images/4_of_clubs.png' },
-        { id: 'five_of_clubs', src: G.BASE_URL + 'images/5_of_clubs.png' },
-        { id: 'six_of_clubs', src: G.BASE_URL + 'images/6_of_clubs.png' },
-        { id: 'seven_of_clubs', src: G.BASE_URL + 'images/7_of_clubs.png' },
-        { id: 'eight_of_clubs', src: G.BASE_URL + 'images/8_of_clubs.png' },
-        { id: 'nine_of_clubs', src: G.BASE_URL + 'images/9_of_clubs.png' },
-        { id: 'ten_of_clubs', src: G.BASE_URL + 'images/10_of_clubs.png' },
-        { id: 'jack_of_clubs', src: G.BASE_URL + 'images/jack_of_clubs.png' },
-        { id: 'queen_of_clubs', src: G.BASE_URL + 'images/queen_of_clubs.png' },
-        { id: 'king_of_clubs', src: G.BASE_URL + 'images/king_of_clubs.png' },
+        { id: 'ace_of_clubs', src: BASE_URL + 'images/ace_of_clubs.png' },
+        { id: 'two_of_clubs', src: BASE_URL + 'images/2_of_clubs.png' },
+        { id: 'three_of_clubs', src: BASE_URL + 'images/3_of_clubs.png' },
+        { id: 'four_of_clubs', src: BASE_URL + 'images/4_of_clubs.png' },
+        { id: 'five_of_clubs', src: BASE_URL + 'images/5_of_clubs.png' },
+        { id: 'six_of_clubs', src: BASE_URL + 'images/6_of_clubs.png' },
+        { id: 'seven_of_clubs', src: BASE_URL + 'images/7_of_clubs.png' },
+        { id: 'eight_of_clubs', src: BASE_URL + 'images/8_of_clubs.png' },
+        { id: 'nine_of_clubs', src: BASE_URL + 'images/9_of_clubs.png' },
+        { id: 'ten_of_clubs', src: BASE_URL + 'images/10_of_clubs.png' },
+        { id: 'jack_of_clubs', src: BASE_URL + 'images/jack_of_clubs.png' },
+        { id: 'queen_of_clubs', src: BASE_URL + 'images/queen_of_clubs.png' },
+        { id: 'king_of_clubs', src: BASE_URL + 'images/king_of_clubs.png' },
 
-        { id: 'ace_of_diamonds', src: G.BASE_URL + 'images/ace_of_diamonds.png' },
-        { id: 'two_of_diamonds', src: G.BASE_URL + 'images/2_of_diamonds.png' },
-        { id: 'three_of_diamonds', src: G.BASE_URL + 'images/3_of_diamonds.png' },
-        { id: 'four_of_diamonds', src: G.BASE_URL + 'images/4_of_diamonds.png' },
-        { id: 'five_of_diamonds', src: G.BASE_URL + 'images/5_of_diamonds.png' },
-        { id: 'six_of_diamonds', src: G.BASE_URL + 'images/6_of_diamonds.png' },
-        { id: 'seven_of_diamonds', src: G.BASE_URL + 'images/7_of_diamonds.png' },
-        { id: 'eight_of_diamonds', src: G.BASE_URL + 'images/8_of_diamonds.png' },
-        { id: 'nine_of_diamonds', src: G.BASE_URL + 'images/9_of_diamonds.png' },
-        { id: 'ten_of_diamonds', src: G.BASE_URL + 'images/10_of_diamonds.png' },
-        { id: 'jack_of_diamonds', src: G.BASE_URL + 'images/jack_of_diamonds.png' },
-        { id: 'queen_of_diamonds', src: G.BASE_URL + 'images/queen_of_diamonds.png' },
-        { id: 'king_of_diamonds', src: G.BASE_URL + 'images/king_of_diamonds.png' },
+        { id: 'ace_of_diamonds', src: BASE_URL + 'images/ace_of_diamonds.png' },
+        { id: 'two_of_diamonds', src: BASE_URL + 'images/2_of_diamonds.png' },
+        { id: 'three_of_diamonds', src: BASE_URL + 'images/3_of_diamonds.png' },
+        { id: 'four_of_diamonds', src: BASE_URL + 'images/4_of_diamonds.png' },
+        { id: 'five_of_diamonds', src: BASE_URL + 'images/5_of_diamonds.png' },
+        { id: 'six_of_diamonds', src: BASE_URL + 'images/6_of_diamonds.png' },
+        { id: 'seven_of_diamonds', src: BASE_URL + 'images/7_of_diamonds.png' },
+        { id: 'eight_of_diamonds', src: BASE_URL + 'images/8_of_diamonds.png' },
+        { id: 'nine_of_diamonds', src: BASE_URL + 'images/9_of_diamonds.png' },
+        { id: 'ten_of_diamonds', src: BASE_URL + 'images/10_of_diamonds.png' },
+        { id: 'jack_of_diamonds', src: BASE_URL + 'images/jack_of_diamonds.png' },
+        { id: 'queen_of_diamonds', src: BASE_URL + 'images/queen_of_diamonds.png' },
+        { id: 'king_of_diamonds', src: BASE_URL + 'images/king_of_diamonds.png' },
 
-        { id: 'ace_of_spades', src: G.BASE_URL + 'images/ace_of_spades.png' },
-        { id: 'two_of_spades', src: G.BASE_URL + 'images/2_of_spades.png' },
-        { id: 'three_of_spades', src: G.BASE_URL + 'images/3_of_spades.png' },
-        { id: 'four_of_spades', src: G.BASE_URL + 'images/4_of_spades.png' },
-        { id: 'five_of_spades', src: G.BASE_URL + 'images/5_of_spades.png' },
-        { id: 'six_of_spades', src: G.BASE_URL + 'images/6_of_spades.png' },
-        { id: 'seven_of_spades', src: G.BASE_URL + 'images/7_of_spades.png' },
-        { id: 'eight_of_spades', src: G.BASE_URL + 'images/8_of_spades.png' },
-        { id: 'nine_of_spades', src: G.BASE_URL + 'images/9_of_spades.png' },
-        { id: 'ten_of_spades', src: G.BASE_URL + 'images/10_of_spades.png' },
-        { id: 'jack_of_spades', src: G.BASE_URL + 'images/jack_of_spades.png' },
-        { id: 'queen_of_spades', src: G.BASE_URL + 'images/queen_of_spades.png' },
-        { id: 'king_of_spades', src: G.BASE_URL + 'images/king_of_spades.png' },
+        { id: 'ace_of_spades', src: BASE_URL + 'images/ace_of_spades.png' },
+        { id: 'two_of_spades', src: BASE_URL + 'images/2_of_spades.png' },
+        { id: 'three_of_spades', src: BASE_URL + 'images/3_of_spades.png' },
+        { id: 'four_of_spades', src: BASE_URL + 'images/4_of_spades.png' },
+        { id: 'five_of_spades', src: BASE_URL + 'images/5_of_spades.png' },
+        { id: 'six_of_spades', src: BASE_URL + 'images/6_of_spades.png' },
+        { id: 'seven_of_spades', src: BASE_URL + 'images/7_of_spades.png' },
+        { id: 'eight_of_spades', src: BASE_URL + 'images/8_of_spades.png' },
+        { id: 'nine_of_spades', src: BASE_URL + 'images/9_of_spades.png' },
+        { id: 'ten_of_spades', src: BASE_URL + 'images/10_of_spades.png' },
+        { id: 'jack_of_spades', src: BASE_URL + 'images/jack_of_spades.png' },
+        { id: 'queen_of_spades', src: BASE_URL + 'images/queen_of_spades.png' },
+        { id: 'king_of_spades', src: BASE_URL + 'images/king_of_spades.png' },
 
-        { id: 'ace_of_hearts', src: G.BASE_URL + 'images/ace_of_hearts.png' },
-        { id: 'two_of_hearts', src: G.BASE_URL + 'images/2_of_hearts.png' },
-        { id: 'three_of_hearts', src: G.BASE_URL + 'images/3_of_hearts.png' },
-        { id: 'four_of_hearts', src: G.BASE_URL + 'images/4_of_hearts.png' },
-        { id: 'five_of_hearts', src: G.BASE_URL + 'images/5_of_hearts.png' },
-        { id: 'six_of_hearts', src: G.BASE_URL + 'images/6_of_hearts.png' },
-        { id: 'seven_of_hearts', src: G.BASE_URL + 'images/7_of_hearts.png' },
-        { id: 'eight_of_hearts', src: G.BASE_URL + 'images/8_of_hearts.png' },
-        { id: 'nine_of_hearts', src: G.BASE_URL + 'images/9_of_hearts.png' },
-        { id: 'ten_of_hearts', src: G.BASE_URL + 'images/10_of_hearts.png' },
-        { id: 'jack_of_hearts', src: G.BASE_URL + 'images/jack_of_hearts.png' },
-        { id: 'queen_of_hearts', src: G.BASE_URL + 'images/queen_of_hearts.png' },
-        { id: 'king_of_hearts', src: G.BASE_URL + 'images/king_of_hearts.png' },
+        { id: 'ace_of_hearts', src: BASE_URL + 'images/ace_of_hearts.png' },
+        { id: 'two_of_hearts', src: BASE_URL + 'images/2_of_hearts.png' },
+        { id: 'three_of_hearts', src: BASE_URL + 'images/3_of_hearts.png' },
+        { id: 'four_of_hearts', src: BASE_URL + 'images/4_of_hearts.png' },
+        { id: 'five_of_hearts', src: BASE_URL + 'images/5_of_hearts.png' },
+        { id: 'six_of_hearts', src: BASE_URL + 'images/6_of_hearts.png' },
+        { id: 'seven_of_hearts', src: BASE_URL + 'images/7_of_hearts.png' },
+        { id: 'eight_of_hearts', src: BASE_URL + 'images/8_of_hearts.png' },
+        { id: 'nine_of_hearts', src: BASE_URL + 'images/9_of_hearts.png' },
+        { id: 'ten_of_hearts', src: BASE_URL + 'images/10_of_hearts.png' },
+        { id: 'jack_of_hearts', src: BASE_URL + 'images/jack_of_hearts.png' },
+        { id: 'queen_of_hearts', src: BASE_URL + 'images/queen_of_hearts.png' },
+        { id: 'king_of_hearts', src: BASE_URL + 'images/king_of_hearts.png' },
 
-        { id: 'pass_left', src: G.BASE_URL + 'images/pass_left.png' },
-        { id: 'pass_right', src: G.BASE_URL + 'images/pass_right.png' },
-        { id: 'pass_across', src: G.BASE_URL + 'images/pass_across.png' }
+        { id: 'pass_left', src: BASE_URL + 'images/pass_left.png' },
+        { id: 'pass_right', src: BASE_URL + 'images/pass_right.png' },
+        { id: 'pass_across', src: BASE_URL + 'images/pass_across.png' }
     ];
+
+var loadMessage = document.querySelector( '#LoadMessage' );
+
+var left = $( window ).width() / 2;
+var top = $( window ).height() / 2;
+
+$( loadMessage ).css( 'top', top + 'px' );
+$( loadMessage ).css( 'left', left + 'px' );
+
 G.PRELOAD.addEventListener( 'progress', function( event )
     {
-        // (event.progress * 100 | 0) + '%'
+    $( loadMessage ).text( (event.progress * 100 | 0) + '%' );
     });
-G.PRELOAD.addEventListener( 'complete', Game.start );
+G.PRELOAD.addEventListener( 'complete', function()
+    {
+    $( loadMessage ).css( 'display', 'none' );
+
+    Game.start()
+    });
 G.PRELOAD.loadManifest( manifest, true );
 };
 

File scripts/player.ts

                 Cards.setAvailable( card );
                 }
             }
+
+        this.selectedCards.length = 0;
         }